diff --git a/.stylua.toml b/.stylua.toml new file mode 100644 index 0000000..440061b --- /dev/null +++ b/.stylua.toml @@ -0,0 +1,3 @@ +indent_type = "Spaces" +call_parentheses = "None" +collapse_simple_statement = "Always" diff --git a/cspell.json b/cspell.json new file mode 100644 index 0000000..39ce496 --- /dev/null +++ b/cspell.json @@ -0,0 +1,19 @@ +{ + "flagWords": [], + "words": [ + "builtins", + "gitsigns", + "autoflake", + "beautysh", + "fixjson", + "fprettify", + "isort", + "nixfmt", + "mdformat", + "nixpkgs", + "shellharden", + "stylua" + ], + "version": "0.2", + "language": "en" +} diff --git a/lua/lsp/attach.lua b/lua/lsp/attach.lua index 1bff195..3ae2970 100644 --- a/lua/lsp/attach.lua +++ b/lua/lsp/attach.lua @@ -1,12 +1,3 @@ --- LSP format call with options -local lsp_formatting = function(bufnr) - vim.lsp.buf.format { - bufnr = bufnr, - timeout_ms = 2000, - async = true, - } -end - -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer local on_attach = function(client, bufnr) @@ -20,7 +11,18 @@ local on_attach = function(client, bufnr) vim.keymap.set("n", "D", vim.lsp.buf.type_definition, bufopts) vim.keymap.set("n", "rn", vim.lsp.buf.rename, bufopts) vim.keymap.set("n", "ca", vim.lsp.buf.code_action, bufopts) - vim.keymap.set("n", "i", lsp_formatting, bufopts) + vim.keymap.set( + "n", + "i", + function() vim.lsp.buf.format { bufnr = bufnr, timeout_ms = 2000, async = true } end, + bufopts + ) + + -- specific client tweaks + if client.name ~= "null-ls" then client.server_capabilities.documentFormattingProvider = false end + if client.name == "ruff_lsp" then client.server_capabilities.hoverProvider = false end + + -- Attach navic and navbuddy if applicable if client.server_capabilities.documentSymbolProvider then require("nvim-navic").attach(client, bufnr) require("nvim-navbuddy").attach(client, bufnr) diff --git a/lua/lsp/null_ls_sources.lua b/lua/lsp/null_ls_sources.lua index fd8cebe..c9707f8 100644 --- a/lua/lsp/null_ls_sources.lua +++ b/lua/lsp/null_ls_sources.lua @@ -1,8 +1,23 @@ local null_ls = require "null-ls" +local cspell = require "cspell" return { + cspell.code_actions, null_ls.builtins.code_actions.gitsigns, + + cspell.diagnostics, + + null_ls.builtins.formatting.alejandra, + null_ls.builtins.formatting.autoflake, + null_ls.builtins.formatting.beautysh, null_ls.builtins.formatting.black, + null_ls.builtins.formatting.fixjson, + -- null_ls.builtins.formatting.fprettify, null_ls.builtins.formatting.isort, - null_ls.builtins.formatting.prettier, - null_ls.builtins.formatting.trim_whitespace, + null_ls.builtins.formatting.mdformat, + -- null_ls.builtins.formatting.nixfmt, + -- null_ls.builtins.formatting.nixpkgs_fmt, + null_ls.builtins.formatting.shellharden, + null_ls.builtins.formatting.stylua, + + null_ls.builtins.hover.dictionary, } diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index 69298c5..507695b 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -9,7 +9,7 @@ return { { "L3MON4D3/LuaSnip", dependencies = { "hrsh7th/nvim-cmp", "saadparwaiz1/cmp_luasnip" } }, { "windwp/nvim-autopairs", dependencies = { "hrsh7th/nvim-cmp" } }, { "folke/neodev.nvim", dependencies = { "hrsh7th/nvim-cmp" } }, - "jose-elias-alvarez/null-ls.nvim", + { "jose-elias-alvarez/null-ls.nvim", dependencies = { "davidmh/cspell.nvim" } }, }, config = function() require "lsp.config"