neovim lsp refactor

remove null-ls (archived, deprecated)
replace formatting with conform.nvim
replace diagnostics with nvim-lint
fixed issue where overlay neovim plugins weren't being applied
This commit is contained in:
Noah Masur 2024-02-10 21:04:37 -05:00
parent 2217568a59
commit cf77adb366
7 changed files with 182 additions and 161 deletions

View File

@ -1,22 +1,5 @@
{ {
"nodes": { "nodes": {
"Comment-nvim-src": {
"flake": false,
"locked": {
"lastModified": 1681214440,
"narHash": "sha256-48hy+hiaDJLlgWqC7IeZI3dT+VwWkRo4atQbyPxu/ys=",
"owner": "numToStr",
"repo": "Comment.nvim",
"rev": "e51f2b142d88bb666dcaa77d93a07f4b419aca70",
"type": "github"
},
"original": {
"owner": "numToStr",
"ref": "v0.8.0",
"repo": "Comment.nvim",
"type": "github"
}
},
"baleia-nvim-src": { "baleia-nvim-src": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -82,6 +65,23 @@
"type": "github" "type": "github"
} }
}, },
"comment-nvim-src": {
"flake": false,
"locked": {
"lastModified": 1681214440,
"narHash": "sha256-48hy+hiaDJLlgWqC7IeZI3dT+VwWkRo4atQbyPxu/ys=",
"owner": "numToStr",
"repo": "Comment.nvim",
"rev": "e51f2b142d88bb666dcaa77d93a07f4b419aca70",
"type": "github"
},
"original": {
"owner": "numToStr",
"ref": "v0.8.0",
"repo": "Comment.nvim",
"type": "github"
}
},
"darwin": { "darwin": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -390,22 +390,6 @@
"type": "github" "type": "github"
} }
}, },
"null-ls-nvim-src": {
"flake": false,
"locked": {
"lastModified": 1691810493,
"narHash": "sha256-cWA0rzkOp/ekVKaFee7iea1lhnqKtWUIU+fW5M950wI=",
"owner": "jose-elias-alvarez",
"repo": "null-ls.nvim",
"rev": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7",
"type": "github"
},
"original": {
"owner": "jose-elias-alvarez",
"repo": "null-ls.nvim",
"type": "github"
}
},
"nur": { "nur": {
"locked": { "locked": {
"lastModified": 1707013032, "lastModified": 1707013032,
@ -421,6 +405,22 @@
"type": "github" "type": "github"
} }
}, },
"nvim-lint-src": {
"flake": false,
"locked": {
"lastModified": 1707389610,
"narHash": "sha256-o2XCMJOySY7A40yS8/aFqhOSpPWTleD4DnOMssSKmXc=",
"owner": "mfussenegger",
"repo": "nvim-lint",
"rev": "966ab3dc37eee3e413692264b44a3011b05a6060",
"type": "github"
},
"original": {
"owner": "mfussenegger",
"repo": "nvim-lint",
"type": "github"
}
},
"nvim-lspconfig-src": { "nvim-lspconfig-src": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -518,11 +518,11 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"Comment-nvim-src": "Comment-nvim-src",
"baleia-nvim-src": "baleia-nvim-src", "baleia-nvim-src": "baleia-nvim-src",
"bufferline-nvim-src": "bufferline-nvim-src", "bufferline-nvim-src": "bufferline-nvim-src",
"bypass-paywalls-clean": "bypass-paywalls-clean", "bypass-paywalls-clean": "bypass-paywalls-clean",
"cmp-nvim-lsp-src": "cmp-nvim-lsp-src", "cmp-nvim-lsp-src": "cmp-nvim-lsp-src",
"comment-nvim-src": "comment-nvim-src",
"darwin": "darwin", "darwin": "darwin",
"disko": "disko", "disko": "disko",
"fidget-nvim-src": "fidget-nvim-src", "fidget-nvim-src": "fidget-nvim-src",
@ -537,8 +537,8 @@
"nix2vim": "nix2vim", "nix2vim": "nix2vim",
"nixos-generators": "nixos-generators", "nixos-generators": "nixos-generators",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"null-ls-nvim-src": "null-ls-nvim-src",
"nur": "nur", "nur": "nur",
"nvim-lint-src": "nvim-lint-src",
"nvim-lspconfig-src": "nvim-lspconfig-src", "nvim-lspconfig-src": "nvim-lspconfig-src",
"nvim-tree-lua-src": "nvim-tree-lua-src", "nvim-tree-lua-src": "nvim-tree-lua-src",
"nvim-treesitter-src": "nvim-treesitter-src", "nvim-treesitter-src": "nvim-treesitter-src",

View File

@ -69,16 +69,12 @@
url = "github:hrsh7th/cmp-nvim-lsp"; url = "github:hrsh7th/cmp-nvim-lsp";
flake = false; flake = false;
}; };
null-ls-nvim-src = {
url = "github:jose-elias-alvarez/null-ls.nvim";
flake = false;
};
baleia-nvim-src = { baleia-nvim-src = {
# https://github.com/m00qek/baleia.nvim/tags # https://github.com/m00qek/baleia.nvim/tags
url = "github:m00qek/baleia.nvim"; url = "github:m00qek/baleia.nvim";
flake = false; flake = false;
}; };
Comment-nvim-src = { comment-nvim-src = {
# https://github.com/numToStr/Comment.nvim/releases # https://github.com/numToStr/Comment.nvim/releases
url = "github:numToStr/Comment.nvim/v0.8.0"; url = "github:numToStr/Comment.nvim/v0.8.0";
flake = false; flake = false;
@ -124,6 +120,10 @@
url = "github:mikesmithgh/kitty-scrollback.nvim"; url = "github:mikesmithgh/kitty-scrollback.nvim";
flake = false; flake = false;
}; };
nvim-lint-src = {
url = "github:mfussenegger/nvim-lint";
flake = false;
};
# Tree-Sitter Grammars # Tree-Sitter Grammars
tree-sitter-bash = { tree-sitter-bash = {
@ -375,6 +375,10 @@
path = ./templates/haskell; path = ./templates/haskell;
description = "Haskell template"; description = "Haskell template";
}; };
rust = {
path = ./templates/rust;
description = "Rust template";
};
}; };
}; };

View File

@ -6,23 +6,12 @@
options.kubernetes = options.kubernetes =
lib.mkEnableOption "Whether to enable Kubernetes features"; lib.mkEnableOption "Whether to enable Kubernetes features";
config = config = {
let
terraformFormat = if config.terraform then ''
require("null-ls").builtins.formatting.terraform_fmt.with({
command = "${pkgs.terraform}/bin/terraform",
extra_filetypes = { "hcl" },
}),
'' else
"";
in {
plugins = [ plugins = [
pkgs.vimPlugins.nvim-lspconfig pkgs.vimPlugins.nvim-lspconfig
pkgs.vimPlugins.null-ls-nvim pkgs.vimPlugins.conform-nvim
pkgs.vimPlugins.fidget-nvim pkgs.vimPlugins.fidget-nvim
pkgs.vimPlugins.nvim-lint
]; ];
setup.fidget = { }; setup.fidget = { };
@ -59,50 +48,60 @@
}; };
}; };
vim.api.nvim_create_augroup = dsl.callWith [ "LspFormatting" { } ]; setup.conform = {
format_on_save = {
# These options will be passed to conform.format()
timeout_ms = 500;
lsp_fallback = true;
};
formatters_by_ft = {
lua = [ "stylua" ];
python = [ "black" ];
fish = [ "fish_indent" ];
nix = [ "nixfmt" ];
rust = [ "rustfmt" ];
sh = [ "shfmt" ];
terraform = if config.terraform then [ "terraform_fmt" ] else [ ];
hcl = if config.terraform then [ "terraform_fmt" ] else [ ];
};
formatters = {
lua.command = "${pkgs.stylua}/bin/stylua";
black.command = "${pkgs.black}/bin/black";
fish_indent.command = "${pkgs.fish}/bin/fish_indent";
nixfmt.command = "${pkgs.nixfmt}/bin/nixfmt";
rustfmt = {
command = "${pkgs.rustfmt}/bin/rustfmt";
prepend_args = [ "--edition" "2021" ];
};
shfmt = {
command = "${pkgs.shfmt}/bin/shfmt";
prepend_args = [ "-i" "4" "-ci" ];
};
terraform_fmt.command =
if config.terraform then "${pkgs.terraform}/bin/terraform" else "";
};
};
use.lint = {
linters_by_ft = dsl.toTable {
python = [ "ruff" ];
sh = [ "shellcheck" ];
};
};
vim.api.nvim_create_autocmd = dsl.callWith [
(dsl.toTable [ "BufEnter" "BufWritePost" ])
(dsl.rawLua "{ callback = function() require('lint').try_lint() end }")
];
lua = '' lua = ''
${builtins.readFile ./lsp.lua} ${builtins.readFile ./lsp.lua}
local ruff = require('lint').linters.ruff; ruff.cmd = "${pkgs.ruff}/bin/ruff"
local shellcheck = require('lint').linters.shellcheck; shellcheck.cmd = "${pkgs.shellcheck}/bin/shellcheck"
-- Prevent infinite log size (change this when debugging) -- Prevent infinite log size (change this when debugging)
vim.lsp.set_log_level("off") vim.lsp.set_log_level("off")
require("null-ls").setup({
sources = {
require("null-ls").builtins.formatting.stylua.with({ command = "${pkgs.stylua}/bin/stylua" }),
require("null-ls").builtins.formatting.black.with({ command = "${pkgs.black}/bin/black" }),
require("null-ls").builtins.diagnostics.ruff.with({ command = "${pkgs.ruff}/bin/ruff" }),
require("null-ls").builtins.formatting.fish_indent.with({ command = "${pkgs.fish}/bin/fish_indent" }),
require("null-ls").builtins.formatting.nixfmt.with({ command = "${pkgs.nixfmt}/bin/nixfmt" }),
require("null-ls").builtins.formatting.rustfmt.with({ command = "${pkgs.rustfmt}/bin/rustfmt" }),
require("null-ls").builtins.diagnostics.shellcheck.with({ command = "${pkgs.shellcheck}/bin/shellcheck" }),
require("null-ls").builtins.formatting.shfmt.with({
command = "${pkgs.shfmt}/bin/shfmt",
extra_args = { "-i", "4", "-ci" },
}),
${terraformFormat}
},
on_attach = function(client, bufnr)
if client.supports_method("textDocument/formatting") then
-- Auto-format on save
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({ bufnr = bufnr })
end,
})
-- Use internal formatting for bindings like gq.
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
vim.bo[args.buf].formatexpr = nil
end,
})
end
end,
})
''; '';
}; };

View File

@ -8,7 +8,7 @@
pkgs.vimPlugins.glow-nvim # Markdown preview popup pkgs.vimPlugins.glow-nvim # Markdown preview popup
pkgs.vimPlugins.nvim-colorizer-lua # Hex color previews pkgs.vimPlugins.nvim-colorizer-lua # Hex color previews
pkgs.vimPlugins.which-key-nvim # Keybind helper pkgs.vimPlugins.which-key-nvim # Keybind helper
pkgs.kitty-scrollback-nvim # Scrollback pager for kitty pkgs.vimPlugins.kitty-scrollback-nvim # Scrollback pager for kitty
]; ];
# Initialize some plugins # Initialize some plugins

View File

@ -24,8 +24,8 @@
pkgs.vimPlugins.playground # Tree-sitter experimenting pkgs.vimPlugins.playground # Tree-sitter experimenting
pkgs.vimPlugins.nginx-vim pkgs.vimPlugins.nginx-vim
pkgs.vimPlugins.vim-helm pkgs.vimPlugins.vim-helm
pkgs.baleia-nvim # Clean ANSI from kitty scrollback pkgs.vimPlugins.baleia-nvim # Clean ANSI from kitty scrollback
# pkgs.hmts-nvim # Tree-sitter injections for home-manager # pkgs.vimPlugins.hmts-nvim # Tree-sitter injections for home-manager
(pkgs.vimUtils.buildVimPlugin { (pkgs.vimUtils.buildVimPlugin {
pname = "nmasur"; pname = "nmasur";
version = "0.1"; version = "0.1";

View File

@ -1,4 +1,4 @@
{ config, lib, ... }: { { config, pkgs, lib, ... }: {
options = { options = {
@ -31,11 +31,22 @@
}; };
# Allow writing custom scripts outside of Nix
# Probably shouldn't make this a habit
environment.localBinInPath = true;
home-manager.users.${config.user}.xdg = { home-manager.users.${config.user}.xdg = {
# Allow Nix to manage the default applications list # Allow Nix to manage the default applications list
mimeApps.enable = true; mimeApps.enable = true;
# Create a desktop option for Burp
desktopEntries.burp = lib.mkIf pkgs.stdenv.isLinux {
name = "Burp";
exec = "${config.homePath}/.local/bin/burp.sh";
categories = [ "Application" ];
};
# Set directories for application defaults # Set directories for application defaults
userDirs = { userDirs = {
enable = true; enable = true;

View File

@ -16,21 +16,26 @@ let
in { in {
nvim-lspconfig = withSrc prev.vimPlugins.nvim-lspconfig inputs.nvim-lspconfig; vimPlugins = prev.vimPlugins // {
cmp-nvim-lsp = withSrc prev.vimPlugins.cmp-nvim-lsp inputs.cmp-nvim-lsp;
null-ls-nvim = withSrc prev.vimPlugins.null-ls-nvim inputs.null-ls-nvim; nvim-lspconfig =
comment-nvim = withSrc prev.vimPlugins.comment-nvim inputs.comment-nvim; withSrc prev.vimPlugins.nvim-lspconfig inputs.nvim-lspconfig-src;
cmp-nvim-lsp = withSrc prev.vimPlugins.cmp-nvim-lsp inputs.cmp-nvim-lsp-src;
comment-nvim = withSrc prev.vimPlugins.comment-nvim inputs.comment-nvim-src;
nvim-treesitter = nvim-treesitter =
withSrc prev.vimPlugins.nvim-treesitter inputs.nvim-treesitter; withSrc prev.vimPlugins.nvim-treesitter inputs.nvim-treesitter-src;
telescope-nvim = withSrc prev.vimPlugins.telescope-nvim inputs.telescope-nvim; telescope-nvim =
withSrc prev.vimPlugins.telescope-nvim inputs.telescope-nvim-src;
telescope-project-nvim = withSrc prev.vimPlugins.telescope-project-nvim telescope-project-nvim = withSrc prev.vimPlugins.telescope-project-nvim
inputs.telescope-project-nvim; inputs.telescope-project-nvim-src;
toggleterm-nvim = toggleterm-nvim =
withSrc prev.vimPlugins.toggleterm-nvim inputs.toggleterm-nvim; withSrc prev.vimPlugins.toggleterm-nvim inputs.toggleterm-nvim-src;
bufferline-nvim = bufferline-nvim =
withSrc prev.vimPlugins.bufferline-nvim inputs.bufferline-nvim; withSrc prev.vimPlugins.bufferline-nvim inputs.bufferline-nvim-src;
nvim-tree-lua = withSrc prev.vimPlugins.nvim-tree-lua inputs.nvim-tree-lua; nvim-tree-lua =
fidget-nvim = withSrc prev.vimPlugins.fidget-nvim inputs.fidget-nvim; withSrc prev.vimPlugins.nvim-tree-lua inputs.nvim-tree-lua-src;
fidget-nvim = withSrc prev.vimPlugins.fidget-nvim inputs.fidget-nvim-src;
nvim-lint = withSrc prev.vimPlugins.nvim-lint inputs.nvim-lint-src;
# Packaging plugins entirely with Nix # Packaging plugins entirely with Nix
baleia-nvim = plugin "baleia-nvim" inputs.baleia-nvim-src; baleia-nvim = plugin "baleia-nvim" inputs.baleia-nvim-src;
@ -38,4 +43,6 @@ in {
kitty-scrollback-nvim = kitty-scrollback-nvim =
plugin "kitty-scrollback-nvim" inputs.kitty-scrollback-nvim-src; plugin "kitty-scrollback-nvim" inputs.kitty-scrollback-nvim-src;
};
} }