mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-22 07:35:38 +00:00
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:
parent
2217568a59
commit
cf77adb366
70
flake.lock
70
flake.lock
@ -1,22 +1,5 @@
|
||||
{
|
||||
"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": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
@ -82,6 +65,23 @@
|
||||
"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": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
@ -390,22 +390,6 @@
|
||||
"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": {
|
||||
"locked": {
|
||||
"lastModified": 1707013032,
|
||||
@ -421,6 +405,22 @@
|
||||
"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": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
@ -518,11 +518,11 @@
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"Comment-nvim-src": "Comment-nvim-src",
|
||||
"baleia-nvim-src": "baleia-nvim-src",
|
||||
"bufferline-nvim-src": "bufferline-nvim-src",
|
||||
"bypass-paywalls-clean": "bypass-paywalls-clean",
|
||||
"cmp-nvim-lsp-src": "cmp-nvim-lsp-src",
|
||||
"comment-nvim-src": "comment-nvim-src",
|
||||
"darwin": "darwin",
|
||||
"disko": "disko",
|
||||
"fidget-nvim-src": "fidget-nvim-src",
|
||||
@ -537,8 +537,8 @@
|
||||
"nix2vim": "nix2vim",
|
||||
"nixos-generators": "nixos-generators",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"null-ls-nvim-src": "null-ls-nvim-src",
|
||||
"nur": "nur",
|
||||
"nvim-lint-src": "nvim-lint-src",
|
||||
"nvim-lspconfig-src": "nvim-lspconfig-src",
|
||||
"nvim-tree-lua-src": "nvim-tree-lua-src",
|
||||
"nvim-treesitter-src": "nvim-treesitter-src",
|
||||
|
14
flake.nix
14
flake.nix
@ -69,16 +69,12 @@
|
||||
url = "github:hrsh7th/cmp-nvim-lsp";
|
||||
flake = false;
|
||||
};
|
||||
null-ls-nvim-src = {
|
||||
url = "github:jose-elias-alvarez/null-ls.nvim";
|
||||
flake = false;
|
||||
};
|
||||
baleia-nvim-src = {
|
||||
# https://github.com/m00qek/baleia.nvim/tags
|
||||
url = "github:m00qek/baleia.nvim";
|
||||
flake = false;
|
||||
};
|
||||
Comment-nvim-src = {
|
||||
comment-nvim-src = {
|
||||
# https://github.com/numToStr/Comment.nvim/releases
|
||||
url = "github:numToStr/Comment.nvim/v0.8.0";
|
||||
flake = false;
|
||||
@ -124,6 +120,10 @@
|
||||
url = "github:mikesmithgh/kitty-scrollback.nvim";
|
||||
flake = false;
|
||||
};
|
||||
nvim-lint-src = {
|
||||
url = "github:mfussenegger/nvim-lint";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
# Tree-Sitter Grammars
|
||||
tree-sitter-bash = {
|
||||
@ -375,6 +375,10 @@
|
||||
path = ./templates/haskell;
|
||||
description = "Haskell template";
|
||||
};
|
||||
rust = {
|
||||
path = ./templates/rust;
|
||||
description = "Rust template";
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -6,105 +6,104 @@
|
||||
options.kubernetes =
|
||||
lib.mkEnableOption "Whether to enable Kubernetes features";
|
||||
|
||||
config =
|
||||
config = {
|
||||
plugins = [
|
||||
pkgs.vimPlugins.nvim-lspconfig
|
||||
pkgs.vimPlugins.conform-nvim
|
||||
pkgs.vimPlugins.fidget-nvim
|
||||
pkgs.vimPlugins.nvim-lint
|
||||
];
|
||||
|
||||
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 = [
|
||||
pkgs.vimPlugins.nvim-lspconfig
|
||||
pkgs.vimPlugins.null-ls-nvim
|
||||
pkgs.vimPlugins.fidget-nvim
|
||||
];
|
||||
|
||||
setup.fidget = { };
|
||||
|
||||
use.lspconfig.lua_ls.setup = dsl.callWith {
|
||||
settings = { Lua = { diagnostics = { globals = [ "vim" "hs" ]; }; }; };
|
||||
capabilities =
|
||||
dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()";
|
||||
cmd = [ "${pkgs.lua-language-server}/bin/lua-language-server" ];
|
||||
};
|
||||
|
||||
use.lspconfig.nil_ls.setup = dsl.callWith {
|
||||
cmd = [ "${pkgs.nil}/bin/nil" ];
|
||||
capabilities =
|
||||
dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()";
|
||||
};
|
||||
|
||||
use.lspconfig.pyright.setup = dsl.callWith {
|
||||
cmd = [ "${pkgs.pyright}/bin/pyright-langserver" "--stdio" ];
|
||||
};
|
||||
|
||||
use.lspconfig.terraformls.setup = dsl.callWith {
|
||||
cmd = if config.terraform then [
|
||||
"${pkgs.terraform-ls}/bin/terraform-ls"
|
||||
"serve"
|
||||
] else
|
||||
[ "echo" ];
|
||||
};
|
||||
|
||||
use.lspconfig.rust_analyzer.setup = dsl.callWith {
|
||||
cmd = [ "${pkgs.rust-analyzer}/bin/rust-analyzer" ];
|
||||
settings = {
|
||||
"['rust-analyzer']" = { check = { command = "clippy"; }; };
|
||||
};
|
||||
};
|
||||
|
||||
vim.api.nvim_create_augroup = dsl.callWith [ "LspFormatting" { } ];
|
||||
|
||||
lua = ''
|
||||
${builtins.readFile ./lsp.lua}
|
||||
|
||||
-- Prevent infinite log size (change this when debugging)
|
||||
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,
|
||||
})
|
||||
'';
|
||||
setup.fidget = { };
|
||||
|
||||
use.lspconfig.lua_ls.setup = dsl.callWith {
|
||||
settings = { Lua = { diagnostics = { globals = [ "vim" "hs" ]; }; }; };
|
||||
capabilities =
|
||||
dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()";
|
||||
cmd = [ "${pkgs.lua-language-server}/bin/lua-language-server" ];
|
||||
};
|
||||
|
||||
use.lspconfig.nil_ls.setup = dsl.callWith {
|
||||
cmd = [ "${pkgs.nil}/bin/nil" ];
|
||||
capabilities =
|
||||
dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()";
|
||||
};
|
||||
|
||||
use.lspconfig.pyright.setup = dsl.callWith {
|
||||
cmd = [ "${pkgs.pyright}/bin/pyright-langserver" "--stdio" ];
|
||||
};
|
||||
|
||||
use.lspconfig.terraformls.setup = dsl.callWith {
|
||||
cmd = if config.terraform then [
|
||||
"${pkgs.terraform-ls}/bin/terraform-ls"
|
||||
"serve"
|
||||
] else
|
||||
[ "echo" ];
|
||||
};
|
||||
|
||||
use.lspconfig.rust_analyzer.setup = dsl.callWith {
|
||||
cmd = [ "${pkgs.rust-analyzer}/bin/rust-analyzer" ];
|
||||
settings = {
|
||||
"['rust-analyzer']" = { check = { command = "clippy"; }; };
|
||||
};
|
||||
};
|
||||
|
||||
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 = ''
|
||||
${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)
|
||||
vim.lsp.set_log_level("off")
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
pkgs.vimPlugins.glow-nvim # Markdown preview popup
|
||||
pkgs.vimPlugins.nvim-colorizer-lua # Hex color previews
|
||||
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
|
||||
|
@ -24,8 +24,8 @@
|
||||
pkgs.vimPlugins.playground # Tree-sitter experimenting
|
||||
pkgs.vimPlugins.nginx-vim
|
||||
pkgs.vimPlugins.vim-helm
|
||||
pkgs.baleia-nvim # Clean ANSI from kitty scrollback
|
||||
# pkgs.hmts-nvim # Tree-sitter injections for home-manager
|
||||
pkgs.vimPlugins.baleia-nvim # Clean ANSI from kitty scrollback
|
||||
# pkgs.vimPlugins.hmts-nvim # Tree-sitter injections for home-manager
|
||||
(pkgs.vimUtils.buildVimPlugin {
|
||||
pname = "nmasur";
|
||||
version = "0.1";
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ config, lib, ... }: {
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
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 = {
|
||||
|
||||
# Allow Nix to manage the default applications list
|
||||
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
|
||||
userDirs = {
|
||||
enable = true;
|
||||
|
@ -16,26 +16,33 @@ let
|
||||
|
||||
in {
|
||||
|
||||
nvim-lspconfig = withSrc prev.vimPlugins.nvim-lspconfig inputs.nvim-lspconfig;
|
||||
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;
|
||||
comment-nvim = withSrc prev.vimPlugins.comment-nvim inputs.comment-nvim;
|
||||
nvim-treesitter =
|
||||
withSrc prev.vimPlugins.nvim-treesitter inputs.nvim-treesitter;
|
||||
telescope-nvim = withSrc prev.vimPlugins.telescope-nvim inputs.telescope-nvim;
|
||||
telescope-project-nvim = withSrc prev.vimPlugins.telescope-project-nvim
|
||||
inputs.telescope-project-nvim;
|
||||
toggleterm-nvim =
|
||||
withSrc prev.vimPlugins.toggleterm-nvim inputs.toggleterm-nvim;
|
||||
bufferline-nvim =
|
||||
withSrc prev.vimPlugins.bufferline-nvim inputs.bufferline-nvim;
|
||||
nvim-tree-lua = withSrc prev.vimPlugins.nvim-tree-lua inputs.nvim-tree-lua;
|
||||
fidget-nvim = withSrc prev.vimPlugins.fidget-nvim inputs.fidget-nvim;
|
||||
vimPlugins = prev.vimPlugins // {
|
||||
|
||||
# Packaging plugins entirely with Nix
|
||||
baleia-nvim = plugin "baleia-nvim" inputs.baleia-nvim-src;
|
||||
hmts-nvim = plugin "hmts-nvim" inputs.hmts-nvim-src;
|
||||
kitty-scrollback-nvim =
|
||||
plugin "kitty-scrollback-nvim" inputs.kitty-scrollback-nvim-src;
|
||||
nvim-lspconfig =
|
||||
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 =
|
||||
withSrc prev.vimPlugins.nvim-treesitter inputs.nvim-treesitter-src;
|
||||
telescope-nvim =
|
||||
withSrc prev.vimPlugins.telescope-nvim inputs.telescope-nvim-src;
|
||||
telescope-project-nvim = withSrc prev.vimPlugins.telescope-project-nvim
|
||||
inputs.telescope-project-nvim-src;
|
||||
toggleterm-nvim =
|
||||
withSrc prev.vimPlugins.toggleterm-nvim inputs.toggleterm-nvim-src;
|
||||
bufferline-nvim =
|
||||
withSrc prev.vimPlugins.bufferline-nvim inputs.bufferline-nvim-src;
|
||||
nvim-tree-lua =
|
||||
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
|
||||
baleia-nvim = plugin "baleia-nvim" inputs.baleia-nvim-src;
|
||||
hmts-nvim = plugin "hmts-nvim" inputs.hmts-nvim-src;
|
||||
kitty-scrollback-nvim =
|
||||
plugin "kitty-scrollback-nvim" inputs.kitty-scrollback-nvim-src;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user