mirror of
https://github.com/iofq/nvim.nix.git
synced 2026-01-23 08:55:16 -06:00
use vim.lsp.config API
This commit is contained in:
parent
8feb221d41
commit
2bab00d2e3
2 changed files with 15 additions and 21 deletions
|
|
@ -31,20 +31,11 @@ return {
|
||||||
'neovim/nvim-lspconfig',
|
'neovim/nvim-lspconfig',
|
||||||
event = 'VeryLazy',
|
event = 'VeryLazy',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
'folke/snacks.nvim',
|
|
||||||
'folke/trouble.nvim',
|
'folke/trouble.nvim',
|
||||||
'saghen/blink.cmp',
|
'saghen/blink.cmp',
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
local lspconfig = require('lspconfig')
|
vim.lsp.config('gopls', {
|
||||||
local capabilities = vim.tbl_deep_extend(
|
|
||||||
'force',
|
|
||||||
{},
|
|
||||||
require('blink.cmp').get_lsp_capabilities(),
|
|
||||||
vim.lsp.protocol.make_client_capabilities()
|
|
||||||
)
|
|
||||||
lspconfig.gopls.setup {
|
|
||||||
capabilities = capabilities,
|
|
||||||
settings = {
|
settings = {
|
||||||
gopls = {
|
gopls = {
|
||||||
gofumpt = true,
|
gofumpt = true,
|
||||||
|
|
@ -69,12 +60,8 @@ return {
|
||||||
staticcheck = true,
|
staticcheck = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
lspconfig.basedpyright.setup { capabilities = capabilities }
|
vim.lsp.config('lua_ls', {
|
||||||
lspconfig.nil_ls.setup { capabilities = capabilities }
|
|
||||||
lspconfig.phpactor.setup { capabilities = capabilities }
|
|
||||||
lspconfig.lua_ls.setup {
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_init = function(client)
|
on_init = function(client)
|
||||||
local path = client.workspace_folders[1].name
|
local path = client.workspace_folders[1].name
|
||||||
if vim.loop.fs_stat(path .. '/.luarc.json') or vim.loop.fs_stat(path .. '/.luarc.jsonc') then
|
if vim.loop.fs_stat(path .. '/.luarc.json') or vim.loop.fs_stat(path .. '/.luarc.jsonc') then
|
||||||
|
|
@ -96,6 +83,13 @@ return {
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {},
|
Lua = {},
|
||||||
},
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.lsp.enable {
|
||||||
|
'nil_ls',
|
||||||
|
'phpactor',
|
||||||
|
'gopls',
|
||||||
|
'lua_ls',
|
||||||
}
|
}
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('LspAttach', {
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
|
|
@ -139,9 +133,10 @@ return {
|
||||||
vim.keymap.set('n', 'grh', function()
|
vim.keymap.set('n', 'grh', function()
|
||||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
|
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
|
||||||
end, { buffer = ev.buf, noremap = true, silent = true, desc = 'LSP hints toggle' })
|
end, { buffer = ev.buf, noremap = true, silent = true, desc = 'LSP hints toggle' })
|
||||||
|
|
||||||
-- Auto-refresh code lenses
|
-- Auto-refresh code lenses
|
||||||
if client.server_capabilities.codeLensProvider then
|
if client.server_capabilities.codeLensProvider then
|
||||||
vim.api.nvim_create_autocmd({ 'InsertLeave', 'BufWritePost', 'TextChanged' }, {
|
vim.api.nvim_create_autocmd({ 'InsertLeave', 'TextChanged' }, {
|
||||||
group = vim.api.nvim_create_augroup(string.format('lsp-%s-%s', bufnr, client.id), {}),
|
group = vim.api.nvim_create_augroup(string.format('lsp-%s-%s', bufnr, client.id), {}),
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.lsp.codelens.refresh { bufnr = bufnr }
|
vim.lsp.codelens.refresh { bufnr = bufnr }
|
||||||
|
|
|
||||||
|
|
@ -159,10 +159,9 @@ return {
|
||||||
|
|
||||||
local multi = require('mini.keymap').map_multistep
|
local multi = require('mini.keymap').map_multistep
|
||||||
local combo = require('mini.keymap').map_combo
|
local combo = require('mini.keymap').map_combo
|
||||||
|
combo({ 'v', 'i', 's' }, 'wq', '<BS><BS><Esc>l')
|
||||||
combo({ 'v', 'r', 'i', 's' }, 'wq', '<BS><BS><Esc>l')
|
multi({ 'i', 's' }, '<Tab>', { 'vimsnippet_next', 'increase_indent' })
|
||||||
multi({ 'i', 's' }, '<Tab>', { 'blink_accept', 'vimsnippet_next' })
|
multi({ 'i', 's' }, '<S-Tab>', { 'vimsnippet_prev', 'decrease_indent' })
|
||||||
multi({ 'i', 's' }, '<S-Tab>', { 'vimsnippet_prev' })
|
|
||||||
end)
|
end)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue