mirror of
https://github.com/LazyVim/starter.git
synced 2026-07-23 21:11:03 +00:00
Fix lsp
This commit is contained in:
parent
a8b834d859
commit
04b8cb055c
1 changed files with 31 additions and 39 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
local on_attach = function(client, bufnr)
|
local on_attach = function(_, bufnr)
|
||||||
local opts = { noremap = true, silent = true, buffer = bufnr }
|
local opts = { noremap = true, silent = true, buffer = bufnr }
|
||||||
|
|
||||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
||||||
|
|
@ -8,9 +7,7 @@ local on_attach = function(client, bufnr)
|
||||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
||||||
vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, opts)
|
vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, opts)
|
||||||
vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, opts)
|
vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, opts)
|
||||||
vim.keymap.set('n', '<leader>wl', function()
|
vim.keymap.set('n', '<leader>wl', function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, opts)
|
||||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
||||||
end, opts)
|
|
||||||
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, opts)
|
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, opts)
|
||||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
||||||
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, opts)
|
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, opts)
|
||||||
|
|
@ -18,60 +15,55 @@ local on_attach = function(client, bufnr)
|
||||||
vim.keymap.set('n', '<leader>ld', vim.lsp.buf.definition, opts)
|
vim.keymap.set('n', '<leader>ld', vim.lsp.buf.definition, opts)
|
||||||
vim.keymap.set('n', '<leader>lt', vim.lsp.buf.type_definition, opts)
|
vim.keymap.set('n', '<leader>lt', vim.lsp.buf.type_definition, opts)
|
||||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
||||||
vim.keymap.set('n', '<leader>f', function()
|
vim.keymap.set('n', '<leader>f', function() vim.lsp.buf.format { async = true } end, opts)
|
||||||
vim.lsp.buf.format { async = true }
|
|
||||||
end, opts)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local config = function(_, opts)
|
local function config(_, opts)
|
||||||
local lspconfig = require('lspconfig')
|
local caps = require("blink.cmp").get_lsp_capabilities()
|
||||||
for server, config in pairs(opts.servers) do
|
|
||||||
-- passing config.capabilities to blink.cmp merges with the capabilities in your
|
-- define configs
|
||||||
-- `opts[server].capabilities, if you've defined it
|
for server, server_opts in pairs(opts.servers) do
|
||||||
config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities)
|
local cfg = vim.tbl_deep_extend("force", {
|
||||||
lspconfig[server].setup(config)
|
capabilities = caps,
|
||||||
|
on_attach = on_attach,
|
||||||
|
}, server_opts or {})
|
||||||
|
|
||||||
|
-- either of these works; I’ll use the callable form:
|
||||||
|
vim.lsp.config(server, cfg)
|
||||||
|
-- (equivalent alternative)
|
||||||
|
-- vim.lsp.config[server] = cfg
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
-- enable all at once for current & future buffers of those filetypes
|
||||||
|
vim.lsp.enable(vim.tbl_keys(opts.servers))
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
-- "hrsh7th/cmp-nvim-lsp",
|
"saghen/blink.cmp",
|
||||||
'saghen/blink.cmp',
|
{ "williamboman/mason.nvim", build = ":MasonUpdate", config = true },
|
||||||
{
|
|
||||||
"williamboman/mason.nvim",
|
|
||||||
build = ":MasonUpdate",
|
|
||||||
config = true,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"williamboman/mason-lspconfig.nvim",
|
"williamboman/mason-lspconfig.nvim",
|
||||||
dependencies = { "neovim/nvim-lspconfig" },
|
dependencies = { "neovim/nvim-lspconfig" },
|
||||||
config = function()
|
config = function()
|
||||||
require("mason-lspconfig").setup {
|
require("mason-lspconfig").setup {
|
||||||
ensure_installed = {
|
ensure_installed = { "ruby_lsp", "ts_ls", "html", "cssls", "lua_ls" },
|
||||||
"ruby_lsp",
|
|
||||||
"ts_ls",
|
|
||||||
"html",
|
|
||||||
"cssls",
|
|
||||||
"lua_ls",
|
|
||||||
},
|
|
||||||
automatic_installation = true,
|
automatic_installation = true,
|
||||||
automatic_enable = false,
|
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
opts = {
|
opts = {
|
||||||
servers = {
|
servers = {
|
||||||
ruby_lsp = { on_attach = on_attach },
|
ruby_lsp = {},
|
||||||
ts_ls = { on_attach = on_attach },
|
ts_ls = {},
|
||||||
html = { on_attach = on_attach },
|
html = {},
|
||||||
cssls = { on_attach = on_attach },
|
cssls = {},
|
||||||
lua_ls = { on_attach = on_attach },
|
lua_ls = {},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
config = config,
|
config = config,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue