mirror of
https://github.com/pnx/dotfiles
synced 2026-06-16 11:24:55 +02:00
moar nvim: snippets and other things
This commit is contained in:
parent
bcb84e54eb
commit
0fb3cfeef9
14 changed files with 426 additions and 138 deletions
|
|
@ -1,64 +1,66 @@
|
|||
return {
|
||||
'VonHeikemen/lsp-zero.nvim',
|
||||
branch = 'v3.x',
|
||||
dependencies = {
|
||||
'neovim/nvim-lspconfig',
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
"VonHeikemen/lsp-zero.nvim",
|
||||
branch = "v3.x",
|
||||
dependencies = {
|
||||
"neovim/nvim-lspconfig",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
|
||||
-- completion
|
||||
{
|
||||
'hrsh7th/nvim-cmp',
|
||||
version = false,
|
||||
event = "InsertEnter",
|
||||
dependencies = {
|
||||
'hrsh7th/cmp-buffer',
|
||||
'hrsh7th/cmp-path',
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'L3MON4D3/LuaSnip',
|
||||
'onsails/lspkind-nvim',
|
||||
},
|
||||
opts = require('config.cmp'),
|
||||
config = function(_, opts)
|
||||
local cmp = require('cmp')
|
||||
cmp.setup(opts)
|
||||
-- completion
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
version = false,
|
||||
event = "InsertEnter",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-buffer", -- autocomplete from buffer
|
||||
"hrsh7th/cmp-path", -- autocomplete from filesystem
|
||||
"hrsh7th/cmp-nvim-lsp", -- autocomplete from lsp
|
||||
"saadparwaiz1/cmp_luasnip", -- autocomplete from snippet engine
|
||||
"L3MON4D3/LuaSnip", -- snippet engine
|
||||
"onsails/lspkind-nvim", -- icons for kind
|
||||
},
|
||||
opts = require("config.cmp"),
|
||||
config = function(_, opts)
|
||||
local cmp = require("cmp")
|
||||
cmp.setup(opts)
|
||||
|
||||
-- insert () on function completion using autopairs
|
||||
cmp.event:on(
|
||||
'confirm_done',
|
||||
require('nvim-autopairs.completion.cmp').on_confirm_done()
|
||||
)
|
||||
end
|
||||
},
|
||||
},
|
||||
opts = require('config.lsp'),
|
||||
config = function(_, opts)
|
||||
local lsp_zero = require('lsp-zero')
|
||||
local lsp_config = require('lspconfig')
|
||||
local augroup = vim.api.nvim_create_augroup("Lsp", {})
|
||||
local map = require('utils.keys')
|
||||
-- insert () on function completion using autopairs
|
||||
cmp.event:on("confirm_done", require("nvim-autopairs.completion.cmp").on_confirm_done())
|
||||
end,
|
||||
},
|
||||
},
|
||||
opts = require("config.lsp"),
|
||||
config = function(_, opts)
|
||||
local lsp_zero = require("lsp-zero")
|
||||
local lsp_config = require("lspconfig")
|
||||
local augroup = vim.api.nvim_create_augroup("Lsp", {})
|
||||
local map = require("utils.keys")
|
||||
|
||||
lsp_zero.on_attach(function(_, bufnr)
|
||||
for _, v in ipairs(require('config.keymaps').lsp or {}) do
|
||||
map(v, { buffer = bufnr })
|
||||
end
|
||||
end)
|
||||
lsp_zero.on_attach(function(_, bufnr)
|
||||
for _, v in ipairs(require("config.keymaps").lsp or {}) do
|
||||
map(v, { buffer = bufnr })
|
||||
end
|
||||
end)
|
||||
|
||||
for name, server_opt in pairs(opts.servers) do
|
||||
local on_attach = function(_, bufnr)
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
for name, server_opt in pairs(opts.servers) do
|
||||
local on_attach = function(client, bufnr)
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
|
||||
if server_opt.on_save then
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = server_opt.on_save,
|
||||
})
|
||||
end
|
||||
end
|
||||
if server_opt.on_save then
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = server_opt.on_save,
|
||||
})
|
||||
end
|
||||
|
||||
server_opt = vim.tbl_deep_extend("force", {on_attach = on_attach}, server_opt or {})
|
||||
if (opts.document_highlight or false) and client.supports_method('textDocument/documentHighlight')then
|
||||
require("utils.lsp").document_highlight(bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
lsp_config[name].setup(server_opt)
|
||||
end
|
||||
end,
|
||||
server_opt = vim.tbl_deep_extend("force", { on_attach = on_attach }, server_opt or {})
|
||||
|
||||
lsp_config[name].setup(server_opt)
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue