Have on_attach/capabilites associated with each LSP.

main
Joshua Potter 2023-11-20 08:02:47 -07:00
parent 73530c939b
commit 1c5dffb8ed
5 changed files with 26 additions and 4 deletions

View File

@ -8,7 +8,7 @@ let
"Julian/lean.nvim";
config = ''
lua << EOF
require('lean').setup {
require('init.lsp').setup(require('lean')) {
abbreviations = { builtin = true },
mappings = true,
}

View File

@ -2,7 +2,7 @@
{
programs.neovim = {
nvim-lspconfig = ''
require('lspconfig').nil_ls.setup {}
require('init.lsp').setup(require('lspconfig').nil_ls) {}
'';
extraPackages = [ pkgs.nil ];

View File

@ -0,0 +1,22 @@
local M = {}
local function on_attach(client, bufnr)
local opts = { buffer = bufnr }
vim.keymap.set('n', 'gq', function()
vim.lsp.buf.format { async = true }
end, opts)
end
local capabilities = require('cmp_nvim_lsp').default_capabilities()
function M.setup(client)
-- Return a nested function so that we can continue invoking `setup` in the
-- familiar way.
return function(opts)
opts.on_attach = opts.on_attach or on_attach
opts.cabailities = opts.cabailities or capabilities
client.setup(opts)
end
end
return M

View File

@ -1,7 +1,7 @@
local M = {}
function M.nvim_lspconfig()
require('lspconfig').lua_ls.setup {
require('init.lsp').setup(require('lspconfig').lua_ls) {
-- Provide completions, analysis, and location handling for plugins on the
-- vim runtime path.
-- https://github.com/neovim/nvim-lspconfig/blob/48347089666d5b77d054088aa72e4e0b58026e6e/doc/server_configurations.md#lua_ls

View File

@ -26,7 +26,7 @@ function M.nvim_dap(options)
end
function M.nvim_lspconfig()
require('lspconfig').pylsp.setup {
require('init.lsp').setup(require('lspconfig').pylsp) {
settings = {
pylsp = {
-- `flake8` currently fails in some cases. Prefer the default set of