lsp-zero new config
This commit is contained in:
1
lua/teeja/lazy/conjure.lua
Normal file
1
lua/teeja/lazy/conjure.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
return { "Olical/conjure" }
|
||||||
@@ -1,22 +1,43 @@
|
|||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
'VonHeikemen/lsp-zero.nvim', branch = 'v3.x',
|
'VonHeikemen/lsp-zero.nvim', branch = 'v4.x',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"neovim/nvim-lspconfig",
|
|
||||||
"williamboman/mason.nvim",
|
"williamboman/mason.nvim",
|
||||||
"williamboman/mason-lspconfig.nvim",
|
"williamboman/mason-lspconfig.nvim",
|
||||||
"hrsh7th/cmp-nvim-lsp",
|
"neovim/nvim-lspconfig",
|
||||||
|
"L3MON4D3/LuaSnip",
|
||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
|
"hrsh7th/cmp-buffer",
|
||||||
"hrsh7th/cmp-path",
|
"hrsh7th/cmp-path",
|
||||||
"L3MON4D3/LuaSnip"
|
"saadparwaiz1/cmp_luasnip",
|
||||||
|
"rafamadriz/friendly-snippets",
|
||||||
},
|
},
|
||||||
|
|
||||||
config = function()
|
config = function()
|
||||||
local lsp_zero = require('lsp-zero')
|
local lsp_zero = require('lsp-zero')
|
||||||
lsp_zero.extend_lspconfig()
|
|
||||||
lsp_zero.on_attach(function(client, bufnr)
|
local lsp_attach = function(client, bufnr)
|
||||||
lsp_zero.default_keymaps({buffer = bufnr})
|
local opts = {buffer = bufnr}
|
||||||
end)
|
|
||||||
|
vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
|
||||||
|
vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
|
||||||
|
vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
|
||||||
|
vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
|
||||||
|
vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts)
|
||||||
|
vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts)
|
||||||
|
vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts)
|
||||||
|
vim.keymap.set('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
|
||||||
|
vim.keymap.set({'n', 'x'}, '<F3>', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts)
|
||||||
|
vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
lsp_zero.extend_lspconfig({
|
||||||
|
sign_text = true,
|
||||||
|
lsp_attach = lsp_attach,
|
||||||
|
float_border = 'rounded',
|
||||||
|
capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
|
})
|
||||||
|
|
||||||
require("mason").setup()
|
require("mason").setup()
|
||||||
require("mason-lspconfig").setup {
|
require("mason-lspconfig").setup {
|
||||||
@@ -30,42 +51,58 @@ return {
|
|||||||
"html",
|
"html",
|
||||||
"dockerls",
|
"dockerls",
|
||||||
"docker_compose_language_service",
|
"docker_compose_language_service",
|
||||||
"intelephense"
|
"intelephense",
|
||||||
}
|
"clojure_lsp"
|
||||||
}
|
};
|
||||||
require("mason-lspconfig").setup_handlers {
|
|
||||||
|
handlers = {
|
||||||
function(server_name)
|
function(server_name)
|
||||||
require("lspconfig")[server_name].setup ({})
|
require('lspconfig')[server_name].setup({})
|
||||||
end,
|
end,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local cmp = require('cmp')
|
local cmp = require('cmp')
|
||||||
local cmp_action = lsp_zero.cmp_action()
|
local cmp_action = lsp_zero.cmp_action()
|
||||||
|
|
||||||
|
-- this is the function that loads the extra snippets
|
||||||
|
-- from rafamadriz/friendly-snippets
|
||||||
|
require('luasnip.loaders.from_vscode').lazy_load()
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
mapping = cmp.mapping.preset.insert({
|
sources = {
|
||||||
-- `Enter` key to confirm completion
|
{name = 'path'},
|
||||||
['<CR>'] = cmp.mapping.confirm({select = false}),
|
{name = 'nvim_lsp'},
|
||||||
|
{name = 'luasnip', keyword_length = 2},
|
||||||
-- Ctrl+Space to trigger completion menu
|
{name = 'buffer', keyword_length = 3},
|
||||||
['<C-Space>'] = cmp.mapping.complete(),
|
},
|
||||||
|
window = {
|
||||||
-- Navigate between snippet placeholder
|
completion = cmp.config.window.bordered(),
|
||||||
['<C-f>'] = cmp_action.luasnip_jump_forward(),
|
documentation = cmp.config.window.bordered(),
|
||||||
['<C-b>'] = cmp_action.luasnip_jump_backward(),
|
},
|
||||||
|
|
||||||
-- Scroll up and down in the completion documentation
|
|
||||||
['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
|
||||||
['<C-d>'] = cmp.mapping.scroll_docs(4),
|
|
||||||
}),
|
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
require('luasnip').lsp_expand(args.body)
|
require('luasnip').lsp_expand(args.body)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
sources = {
|
mapping = cmp.mapping.preset.insert({
|
||||||
{ name = 'path' }
|
-- confirm completion item
|
||||||
}
|
['<Enter>'] = cmp.mapping.confirm({ select = true }),
|
||||||
|
|
||||||
|
-- trigger completion menu
|
||||||
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
|
|
||||||
|
-- scroll up and down the documentation window
|
||||||
|
['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<C-d>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
|
||||||
|
-- navigate between snippet placeholders
|
||||||
|
['<C-f>'] = cmp_action.luasnip_jump_forward(),
|
||||||
|
['<C-b>'] = cmp_action.luasnip_jump_backward(),
|
||||||
|
}),
|
||||||
|
-- note: if you are going to use lsp-kind (another plugin)
|
||||||
|
-- replace the line below with the function from lsp-kind
|
||||||
|
formatting = lsp_zero.cmp_format({details = true}),
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ return {
|
|||||||
"php",
|
"php",
|
||||||
"dockerfile",
|
"dockerfile",
|
||||||
"yaml",
|
"yaml",
|
||||||
"toml"
|
"toml",
|
||||||
|
"clojure"
|
||||||
},
|
},
|
||||||
sync_install = false,
|
sync_install = false,
|
||||||
highlight = { enable = true },
|
highlight = { enable = true },
|
||||||
|
|||||||
Reference in New Issue
Block a user