1
0

feat(nvim): Use vanila neovim lsp client

This commit is contained in:
2025-07-04 21:57:53 +02:00
parent a6f1537b1d
commit b3a59604a3
6 changed files with 113 additions and 229 deletions

View File

@@ -1,200 +0,0 @@
local required = { 'mason', 'mason-lspconfig', 'lspconfig', 'lsp-zero', 'cmp' }
local ready = true
vim.cmd.echohl('WarningMsg')
for _, module in ipairs(required) do
local ok, _ = pcall(require, module)
if not ok then
ready = false
vim.cmd.echo('"Module \'' .. module .. "' isn't present!\"")
end
end
if not ready then
vim.cmd.echo('"LSP disabled!"')
vim.cmd.echohl('None')
return
end
vim.cmd.echohl('None')
local zero = require('lsp-zero')
zero.preset('recommended')
require('mason').setup({})
local settings = {
['lua_ls'] = {
Lua = {
runtime = {
version = 'LuaJIT',
},
workspace = {
library = { vim.env.VIMRUNTIME },
},
},
},
}
require('mason-lspconfig').setup({
ensure_installed = {
'lua_ls',
},
handlers = {
-- zero.default_setup,
function(name)
require('lspconfig')[name].setup({
settings = settings[name] or {},
capabilities = require('cmp_nvim_lsp').default_capabilities(),
})
end,
},
})
zero.on_attach(function(client, bufnr)
local opts = { buffer = bufnr, remap = false }
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
end)
-- #region CMP
local cmp_kind_icons = {
Text = '',
Method = '󰆧',
Function = '󰊕',
Constructor = '',
Field = '󰇽',
Variable = '󰂡',
Class = '󰠱',
Interface = '',
Module = '',
Property = '󰜢',
Unit = '',
Value = '󰎠',
Enum = '',
Keyword = '󰌋',
Snippet = '',
Color = '󰏘',
File = '󰈙',
Reference = '',
Folder = '󰉋',
EnumMember = '',
Constant = '󰏿',
Struct = '',
Event = '',
Operator = '󰆕',
TypeParameter = '󰅲',
}
local cmp = require('cmp')
cmp.setup({
mapping = cmp.mapping.preset.insert({
['<Tab>'] = cmp.mapping.confirm({ select = true }),
}),
snippet = {
expand = function(args)
local luasnip = require('luasnip')
if not luasnip then
return
end
luasnip.lsp_expand(args.body)
end,
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'calc' },
},
window = {
completion = {
winhighlight = 'Normal:Pmeny,FloatBorder:Pmenu,Search:None',
col_offset = -3,
side_padding = 0,
},
-- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(),
},
formatting = {
fields = { 'kind', 'abbr', 'menu' },
format = function(entry, vim_item)
local kind = require('lspkind').cmp_format({ mode = 'symbol_text', maxwidth = 50 })(entry, vim_item)
local strings = vim.split(kind.kind, '%s', { trimempty = true })
kind.kind = ' ' .. (strings[1] or '') .. ' '
kind.menu = ' (' .. (strings[2] or '') .. ')'
return kind
end,
},
})
cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'buffer' },
}),
})
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' },
}, {
{ name = 'cmdline' },
}),
matching = { disallow_symbol_nonprefix_matching = false },
})
-- #region Highlight groups
-- Customization for Pmenu
vim.api.nvim_set_hl(0, 'PmenuSel', { bg = '#282C34', fg = 'NONE' })
vim.api.nvim_set_hl(0, 'Pmenu', { fg = '#C5CDD9', bg = '#22252A' })
vim.api.nvim_set_hl(0, 'CmpItemAbbrDeprecated', { fg = '#7E8294', bg = 'NONE', strikethrough = true })
vim.api.nvim_set_hl(0, 'CmpItemAbbrMatch', { fg = '#82AAFF', bg = 'NONE', bold = true })
vim.api.nvim_set_hl(0, 'CmpItemAbbrMatchFuzzy', { fg = '#82AAFF', bg = 'NONE', bold = true })
vim.api.nvim_set_hl(0, 'CmpItemMenu', { fg = '#C792EA', bg = 'NONE', italic = true })
vim.api.nvim_set_hl(0, 'CmpItemKindField', { fg = '#EED8DA', bg = '#B5585F' })
vim.api.nvim_set_hl(0, 'CmpItemKindProperty', { fg = '#EED8DA', bg = '#B5585F' })
vim.api.nvim_set_hl(0, 'CmpItemKindEvent', { fg = '#EED8DA', bg = '#B5585F' })
vim.api.nvim_set_hl(0, 'CmpItemKindText', { fg = '#C3E88D', bg = '#9FBD73' })
vim.api.nvim_set_hl(0, 'CmpItemKindEnum', { fg = '#C3E88D', bg = '#9FBD73' })
vim.api.nvim_set_hl(0, 'CmpItemKindKeyword', { fg = '#C3E88D', bg = '#9FBD73' })
vim.api.nvim_set_hl(0, 'CmpItemKindConstant', { fg = '#FFE082', bg = '#D4BB6C' })
vim.api.nvim_set_hl(0, 'CmpItemKindConstructor', { fg = '#FFE082', bg = '#D4BB6C' })
vim.api.nvim_set_hl(0, 'CmpItemKindReference', { fg = '#FFE082', bg = '#D4BB6C' })
vim.api.nvim_set_hl(0, 'CmpItemKindFunction', { fg = '#EADFF0', bg = '#A377BF' })
vim.api.nvim_set_hl(0, 'CmpItemKindStruct', { fg = '#EADFF0', bg = '#A377BF' })
vim.api.nvim_set_hl(0, 'CmpItemKindClass', { fg = '#EADFF0', bg = '#A377BF' })
vim.api.nvim_set_hl(0, 'CmpItemKindModule', { fg = '#EADFF0', bg = '#A377BF' })
vim.api.nvim_set_hl(0, 'CmpItemKindOperator', { fg = '#EADFF0', bg = '#A377BF' })
vim.api.nvim_set_hl(0, 'CmpItemKindVariable', { fg = '#C5CDD9', bg = '#7E8294' })
vim.api.nvim_set_hl(0, 'CmpItemKindFile', { fg = '#C5CDD9', bg = '#7E8294' })
vim.api.nvim_set_hl(0, 'CmpItemKindUnit', { fg = '#F5EBD9', bg = '#D4A959' })
vim.api.nvim_set_hl(0, 'CmpItemKindSnippet', { fg = '#F5EBD9', bg = '#D4A959' })
vim.api.nvim_set_hl(0, 'CmpItemKindFolder', { fg = '#F5EBD9', bg = '#D4A959' })
vim.api.nvim_set_hl(0, 'CmpItemKindMethod', { fg = '#DDE5F5', bg = '#6C8ED4' })
vim.api.nvim_set_hl(0, 'CmpItemKindValue', { fg = '#DDE5F5', bg = '#6C8ED4' })
vim.api.nvim_set_hl(0, 'CmpItemKindEnumMember', { fg = '#DDE5F5', bg = '#6C8ED4' })
vim.api.nvim_set_hl(0, 'CmpItemKindInterface', { fg = '#D8EEEB', bg = '#58B5A8' })
vim.api.nvim_set_hl(0, 'CmpItemKindColor', { fg = '#D8EEEB', bg = '#58B5A8' })
vim.api.nvim_set_hl(0, 'CmpItemKindTypeParameter', { fg = '#D8EEEB', bg = '#58B5A8' })
-- #endregion
-- #endregion
vim.diagnostic.config({
severity_sort = true,
})

View File

@@ -1,36 +1,97 @@
local blink_methods = {
icon = function(ctx)
local icon, _, _ = require('mini.icons').get('lsp', ctx.kind)
return icon
end,
highlight = function(ctx)
local _, hi, _ = require('mini.icons').get('lsp', ctx.kind)
vim.print(hi)
return hi
end,
}
return {
-- Mason
{ 'williamboman/mason.nvim', opts = {}, cmd = 'Mason', event = 'VeryLazy' },
{ 'williamboman/mason-lspconfig.nvim', opts = {}, event = 'VeryLazy' },
-- Lsp configuration
{ 'VonHeikemen/lsp-zero.nvim' },
{ 'neovim/nvim-lspconfig' },
-- Completion
{ 'mason-org/mason.nvim', opts = {} },
{
'hrsh7th/nvim-cmp',
event = 'VeryLazy',
dependencies = {
'hrsh7th/cmp-calc',
'hrsh7th/cmp-cmdline',
'hrsh7th/cmp-path',
'hrsh7th/cmp-buffer',
'L3MON4D3/LuaSnip',
'hrsh7th/cmp-nvim-lsp',
'onsails/lspkind.nvim',
},
},
-- Additions
{
'ray-x/lsp_signature.nvim',
event = 'VeryLazy',
'mason-org/mason-lspconfig.nvim',
version = '1.*',
opts = {
hint_prefix = '',
ensure_installed = { 'lua_ls', 'rust_analyzer' },
},
config = function(lazy)
local mlspconfig = require('mason-lspconfig')
mlspconfig.setup(lazy.opts)
mlspconfig.setup_handlers({
vim.lsp.enable,
})
end,
dependencies = {
'mason-org/mason.nvim',
},
},
-- Rust
-- { 'mrcjkb/rustaceanvim' },
{
'Saghen/blink.cmp',
dependencies = {
'echasnovski/mini.icons',
},
version = '1.*',
build = 'cargo build --release',
opts = {
keymap = {
preset = 'default',
['<Up>'] = { 'select_prev', 'fallback' },
['<Down>'] = { 'select_next', 'fallback' },
['<Tab>'] = { 'accept', 'fallback' },
},
appearance = {
nerd_font_variant = 'normal',
},
sources = {
default = { 'lsp', 'buffer', 'path', 'omni' },
},
completion = {
list = { selection = { auto_insert = false } },
documentation = {
auto_show = true,
auto_show_delay_ms = 700,
},
ghost_text = { enabled = true },
menu = {
auto_show = true,
draw = {
columns = { { 'kind_icon' }, { 'label', 'label_description', gap = 1 }, { 'kind' } },
components = {
kind_icon = {
text = blink_methods.icon,
},
kind = {
text = function(ctx)
return '(' .. ctx.kind .. ')'
end,
highlight = 'SpecialKey',
},
},
},
},
},
cmdline = {
enabled = true,
keymap = { preset = 'inherit' },
sources = { 'buffer', 'cmdline' },
completion = {
list = { selection = { preselect = true, auto_insert = false } },
ghost_text = { enabled = true },
menu = {
auto_show = true,
},
},
},
signature = { enabled = true, window = { show_documentation = true } },
},
},
}