Something went wrong. Try again.
My neovim config
Something went wrong. Try again.
2.6 kB · 87 lines
Lua
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788-- LSP configuration-- Tweaks LSP keymaps, gopls settings, and adds harper_ls / nginx serversreturn { "neovim/nvim-lspconfig", event = { "BufReadPre", "BufNewFile", "BufWritePre" }, opts = function(_, opts) opts.servers = opts.servers or {} opts.servers["*"] = opts.servers["*"] or {} opts.servers["*"].keys = opts.servers["*"].keys or {}
vim.list_extend(opts.servers["*"].keys, { -- disable keymaps { "<a-p>", false }, { "<a-n>", false }, -- map cd to LSP rename using inc-rename { "cd", function() local inc_rename = require("inc_rename") return ":" .. inc_rename.config.cmd_name .. " " .. vim.fn.expand("<cword>") end, expr = true, desc = "Rename (inc-rename.nvim)", has = "rename", }, -- map <leader>ca to code actions { "<leader>ca", vim.lsp.buf.code_action, desc = "Code Action", mode = { "n", "x" }, has = "codeAction", }, })
-- configure Go LSP servers opts.servers.gopls = vim.tbl_deep_extend("force", opts.servers.gopls or {}, { settings = { gopls = { staticcheck = false, experimentalPostfixCompletions = true, }, }, }) opts.servers.harper_ls = { filetypes = { "markdown", "gitcommit", "text" } } opts.servers.nginx_language_server = {} -- Mason builds ansible-lint on the stock python3 (3.15), which ansible-core does not support yet opts.servers.ansiblels = vim.tbl_deep_extend("force", opts.servers.ansiblels or {}, { settings = { ansible = { validation = { lint = { path = vim.fn.expand("~/.local/bin/ansible-lint") } }, }, }, })
opts.setup = opts.setup or {}
local copilot_setup = opts.setup.copilot opts.setup.copilot = function(server, sopts) if copilot_setup then copilot_setup(server, sopts) end vim.lsp.config(server, sopts) vim.api.nvim_create_autocmd("InsertEnter", { once = true, callback = function() vim.lsp.enable(server) end, }) return true end
opts.setup.harper_ls = function(server, sopts) vim.lsp.config(server, sopts) Snacks.toggle({ name = "Harper", get = function() return vim.lsp.is_enabled("harper_ls") end, set = function(state) vim.lsp.enable("harper_ls", state) end, }):map("<leader>uH") return true end end,}