fixed vim global, added lsp keys, moved pairs, cmp configured again right
This commit is contained in:
parent
96d8f521be
commit
b6f3df8ab1
5 changed files with 200 additions and 62 deletions
5
.luarc.json
Normal file
5
.luarc.json
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"diagnostics.globals": [
|
||||||
|
"vim"
|
||||||
|
]
|
||||||
|
}
|
|
@ -2,7 +2,9 @@
|
||||||
"LuaSnip": { "branch": "master", "commit": "fb525166ccc30296fb3457441eb979113de46b00" },
|
"LuaSnip": { "branch": "master", "commit": "fb525166ccc30296fb3457441eb979113de46b00" },
|
||||||
"alpha-nvim": { "branch": "main", "commit": "a35468cd72645dbd52c0624ceead5f301c566dff" },
|
"alpha-nvim": { "branch": "main", "commit": "a35468cd72645dbd52c0624ceead5f301c566dff" },
|
||||||
"catppuccin": { "branch": "main", "commit": "fa42eb5e26819ef58884257d5ae95dd0552b9a66" },
|
"catppuccin": { "branch": "main", "commit": "fa42eb5e26819ef58884257d5ae95dd0552b9a66" },
|
||||||
|
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
|
||||||
"cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" },
|
"cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" },
|
||||||
|
"cmp-path": { "branch": "main", "commit": "c6635aae33a50d6010bf1aa756ac2398a2d54c32" },
|
||||||
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
|
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
|
||||||
"codestats.nvim": { "branch": "master", "commit": "041b315c4f82997186fcdb3fc2f687cc128a28f3" },
|
"codestats.nvim": { "branch": "master", "commit": "041b315c4f82997186fcdb3fc2f687cc128a28f3" },
|
||||||
"flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" },
|
"flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" },
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
return {
|
|
||||||
{
|
|
||||||
"windwp/nvim-ts-autotag",
|
|
||||||
config = function()
|
|
||||||
require('nvim-ts-autotag').setup({
|
|
||||||
opts = {
|
|
||||||
enable_close = true, -- Auto close tags
|
|
||||||
enable_rename = true, -- Auto rename pairs of tags
|
|
||||||
enable_close_on_slash = true -- Auto close on trailing </
|
|
||||||
}
|
|
||||||
})
|
|
||||||
end
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"hrsh7th/nvim-cmp",
|
|
||||||
config = function()
|
|
||||||
local cmp = require("cmp")
|
|
||||||
cmp.setup({
|
|
||||||
snippet = {
|
|
||||||
expand = function(args)
|
|
||||||
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
window = {
|
|
||||||
completion = cmp.config.window.bordered(),
|
|
||||||
documentation = cmp.config.window.bordered(),
|
|
||||||
},
|
|
||||||
mapping = cmp.mapping.preset.insert({
|
|
||||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
||||||
['<C-Space>'] = cmp.mapping.complete(),
|
|
||||||
['<C-e>'] = cmp.mapping.abort(),
|
|
||||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
|
||||||
}),
|
|
||||||
sources = cmp.config.sources({
|
|
||||||
{ name = 'nvim_lsp' },
|
|
||||||
{ name = 'luasnip' }, -- For luasnip users.
|
|
||||||
{ name = 'path' },
|
|
||||||
{ name = 'emoji' },
|
|
||||||
}, {
|
|
||||||
{ name = 'buffer' },
|
|
||||||
})
|
|
||||||
})
|
|
||||||
end
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"L3MON4D3/LuaSnip",
|
|
||||||
dependencies = {
|
|
||||||
"rafamadriz/friendly-snippets",
|
|
||||||
"saadparwaiz1/cmp_luasnip",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,14 +3,6 @@ return {
|
||||||
"smjonas/inc-rename.nvim",
|
"smjonas/inc-rename.nvim",
|
||||||
opts = {}
|
opts = {}
|
||||||
},
|
},
|
||||||
-- {
|
|
||||||
-- "mason-org/mason-lspconfig.nvim",
|
|
||||||
-- opts = {},
|
|
||||||
-- dependencies = {
|
|
||||||
-- { "mason-org/mason.nvim", opts = {} },
|
|
||||||
-- "neovim/nvim-lspconfig",
|
|
||||||
-- },
|
|
||||||
-- },
|
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"mason-org/mason-lspconfig.nvim",
|
"mason-org/mason-lspconfig.nvim",
|
||||||
|
@ -20,7 +12,187 @@ return {
|
||||||
dependencies = {
|
dependencies = {
|
||||||
{ "mason-org/mason.nvim", opts = {} },
|
{ "mason-org/mason.nvim", opts = {} },
|
||||||
{ "neovim/nvim-lspconfig" },
|
{ "neovim/nvim-lspconfig" },
|
||||||
|
{ "hrsh7th/nvim-cmp" },
|
||||||
|
{ "hrsh7th/cmp-nvim-lsp" },
|
||||||
|
{ "hrsh7th/cmp-buffer" },
|
||||||
|
{ "hrsh7th/cmp-path" },
|
||||||
|
{ "saadparwaiz1/cmp_luasnip" },
|
||||||
|
{ "L3MON4D3/LuaSnip" },
|
||||||
|
{ "rafamadriz/friendly-snippets" },
|
||||||
},
|
},
|
||||||
|
config = function()
|
||||||
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
|
desc = 'LSP actions',
|
||||||
|
callback = function()
|
||||||
|
local bufmap = function(mode, lhs, rhs)
|
||||||
|
local opts = { buffer = true }
|
||||||
|
vim.keymap.set(mode, lhs, rhs, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
bufmap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>')
|
||||||
|
bufmap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>')
|
||||||
|
bufmap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>')
|
||||||
|
bufmap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>')
|
||||||
|
bufmap('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>')
|
||||||
|
bufmap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>')
|
||||||
|
bufmap('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>')
|
||||||
|
bufmap('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>')
|
||||||
|
bufmap('n', '<F3>', '<cmd>lua vim.lsp.buf.format({async = true})<cr>')
|
||||||
|
bufmap('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>')
|
||||||
|
bufmap('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<cr>')
|
||||||
|
bufmap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>')
|
||||||
|
bufmap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>')
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Diagnostics
|
||||||
|
---
|
||||||
|
|
||||||
|
local sign = function(opts)
|
||||||
|
vim.fn.sign_define(opts.name, {
|
||||||
|
texthl = opts.name,
|
||||||
|
text = opts.text,
|
||||||
|
numhl = ''
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
sign({ name = 'DiagnosticSignError', text = '✘' })
|
||||||
|
sign({ name = 'DiagnosticSignWarn', text = '▲' })
|
||||||
|
sign({ name = 'DiagnosticSignHint', text = '⚑' })
|
||||||
|
sign({ name = 'DiagnosticSignInfo', text = '' })
|
||||||
|
|
||||||
|
vim.diagnostic.config({
|
||||||
|
virtual_text = false,
|
||||||
|
severity_sort = true,
|
||||||
|
float = {
|
||||||
|
border = 'rounded',
|
||||||
|
source = 'always',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(
|
||||||
|
vim.lsp.handlers.hover,
|
||||||
|
{ border = 'rounded' }
|
||||||
|
)
|
||||||
|
|
||||||
|
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(
|
||||||
|
vim.lsp.handlers.signature_help,
|
||||||
|
{ border = 'rounded' }
|
||||||
|
)
|
||||||
|
|
||||||
|
---
|
||||||
|
-- LSP servers
|
||||||
|
---
|
||||||
|
|
||||||
|
-- require('mason').setup({})
|
||||||
|
-- require('mason-lspconfig').setup({})
|
||||||
|
|
||||||
|
local lspconfig = require('lspconfig')
|
||||||
|
local lsp_capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
|
|
||||||
|
lspconfig.tsserver.setup({
|
||||||
|
capabilities = lsp_capabilities,
|
||||||
|
})
|
||||||
|
lspconfig.lua_ls.setup({
|
||||||
|
capabilities = lsp_capabilities,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Autocomplete
|
||||||
|
---
|
||||||
|
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
||||||
|
|
||||||
|
require('luasnip.loaders.from_vscode').lazy_load()
|
||||||
|
|
||||||
|
local cmp = require('cmp')
|
||||||
|
local luasnip = require('luasnip')
|
||||||
|
|
||||||
|
local select_opts = { behavior = cmp.SelectBehavior.Select }
|
||||||
|
|
||||||
|
cmp.setup({
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
luasnip.lsp_expand(args.body)
|
||||||
|
end
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
{ name = 'path' },
|
||||||
|
{ name = 'nvim_lsp', keyword_length = 1 },
|
||||||
|
{ name = 'buffer', keyword_length = 3 },
|
||||||
|
{ name = 'luasnip', keyword_length = 2 },
|
||||||
|
},
|
||||||
|
window = {
|
||||||
|
documentation = cmp.config.window.bordered()
|
||||||
|
},
|
||||||
|
formatting = {
|
||||||
|
fields = { 'menu', 'abbr', 'kind' },
|
||||||
|
format = function(entry, item)
|
||||||
|
local menu_icon = {
|
||||||
|
nvim_lsp = 'λ',
|
||||||
|
luasnip = '⋗',
|
||||||
|
buffer = 'Ω',
|
||||||
|
path = '🖫',
|
||||||
|
}
|
||||||
|
|
||||||
|
item.menu = menu_icon[entry.source.name]
|
||||||
|
return item
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mapping = {
|
||||||
|
['<Up>'] = cmp.mapping.select_prev_item(select_opts),
|
||||||
|
['<Down>'] = cmp.mapping.select_next_item(select_opts),
|
||||||
|
|
||||||
|
['<C-p>'] = cmp.mapping.select_prev_item(select_opts),
|
||||||
|
['<C-n>'] = cmp.mapping.select_next_item(select_opts),
|
||||||
|
|
||||||
|
['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<C-d>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
|
||||||
|
['<C-e>'] = cmp.mapping.abort(),
|
||||||
|
['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
||||||
|
['<CR>'] = cmp.mapping.confirm({ select = false }),
|
||||||
|
|
||||||
|
['<C-f>'] = cmp.mapping(function(fallback)
|
||||||
|
if luasnip.jumpable(1) then
|
||||||
|
luasnip.jump(1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { 'i', 's' }),
|
||||||
|
|
||||||
|
['<C-b>'] = cmp.mapping(function(fallback)
|
||||||
|
if luasnip.jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { 'i', 's' }),
|
||||||
|
|
||||||
|
['<Tab>'] = cmp.mapping(function(fallback)
|
||||||
|
local col = vim.fn.col('.') - 1
|
||||||
|
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item(select_opts)
|
||||||
|
elseif col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
|
||||||
|
fallback()
|
||||||
|
else
|
||||||
|
cmp.complete()
|
||||||
|
end
|
||||||
|
end, { 'i', 's' }),
|
||||||
|
|
||||||
|
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item(select_opts)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { 'i', 's' }),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,6 +2,18 @@ return {
|
||||||
{
|
{
|
||||||
'RRethy/nvim-treesitter-endwise',
|
'RRethy/nvim-treesitter-endwise',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"windwp/nvim-ts-autotag",
|
||||||
|
config = function()
|
||||||
|
require('nvim-ts-autotag').setup({
|
||||||
|
opts = {
|
||||||
|
enable_close = true, -- Auto close tags
|
||||||
|
enable_rename = true, -- Auto rename pairs of tags
|
||||||
|
enable_close_on_slash = true -- Auto close on trailing </
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'windwp/nvim-autopairs',
|
'windwp/nvim-autopairs',
|
||||||
event = "InsertEnter",
|
event = "InsertEnter",
|
||||||
|
|
Loading…
Add table
Reference in a new issue