Compare commits
6 Commits
e64316e336
...
89bca77ef4
Author | SHA1 | Date | |
---|---|---|---|
89bca77ef4 | |||
0bfd392b20 | |||
890fe6f928 | |||
1d1d922282 | |||
2f6b0ba33c | |||
7b17b794f6 |
@ -35,18 +35,27 @@ return {
|
||||
config = function()
|
||||
require('mason').setup()
|
||||
require('mason-lspconfig').setup({
|
||||
ensure_installed = {
|
||||
'clangd',
|
||||
'cmake',
|
||||
'jsonls',
|
||||
'lemminx',
|
||||
'lua_ls',
|
||||
'pyright',
|
||||
'ruff_lsp',
|
||||
'vimls',
|
||||
'yamlls',
|
||||
},
|
||||
automatic_installation = false,
|
||||
ensure_installed = {
|
||||
'ansiblels', -- Ansible
|
||||
'bashls', -- Bash
|
||||
'clangd', -- C/C++
|
||||
'cmake', -- Cmake
|
||||
'docker_compose_language_service', -- Docker Compose
|
||||
'dockerls', -- Dockerfile
|
||||
'esbonio', -- Sphinx
|
||||
'html', -- HTML
|
||||
'jsonls', -- JSON
|
||||
'lemminx', -- XML
|
||||
'lua_ls', -- Lua
|
||||
'opencl_ls', -- OpenCL
|
||||
'powershell_es', -- Powershell
|
||||
'pyright', -- Python
|
||||
'ruff_lsp', -- Python
|
||||
'vimls', -- VimScript
|
||||
'yamlls', -- YAML
|
||||
},
|
||||
|
||||
handlers = {
|
||||
-- Default handler, sets up everything unless a custom language server
|
||||
-- setup handler is defined below
|
||||
@ -89,30 +98,62 @@ return {
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end
|
||||
},
|
||||
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
-- Open completion menu/confirm completion
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-l>'] = cmp.mapping.confirm({ select = true }),
|
||||
-- Select completion from menu
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
-- Scroll documentation of selected completion item
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
||||
}),
|
||||
|
||||
sources = {
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
-- { name = 'buffer' },
|
||||
{ name = 'path' },
|
||||
-- { name = 'cmdline' },
|
||||
},
|
||||
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
})
|
||||
|
||||
-- Disable displaying diagnostics as virtual text
|
||||
vim.diagnostic.config({ virtual_text = false })
|
||||
-- Customise LSP UI
|
||||
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(
|
||||
vim.lsp.handlers.hover, {
|
||||
border = 'rounded',
|
||||
title = 'Hover',
|
||||
}
|
||||
)
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
|
||||
vim.lsp.handlers.signature_help, {
|
||||
border = 'rounded',
|
||||
title = 'Signature Help'
|
||||
}
|
||||
)
|
||||
|
||||
-- Diagnostic mappings
|
||||
-- Customise diagnostics UI
|
||||
vim.diagnostic.config({
|
||||
float = {
|
||||
border = 'rounded', -- Enable rounded border on floats
|
||||
},
|
||||
virtual_text = false, -- Disable trailing virtual text
|
||||
})
|
||||
|
||||
-- Diagnostics mappings
|
||||
-- TODO: trouble.nvim mappings instead? https://youtu.be/MuUrCcvE-Yw?t=631
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { remap = false })
|
||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { remap = false })
|
||||
vim.keymap.set('n', '<leader>sd', vim.diagnostic.open_float, { remap = false })
|
||||
|
||||
-- LSP mappings created when attached to a buffer
|
||||
-- Mappings created when LSP is attached to a buffer
|
||||
local augroup = vim.api.nvim_create_augroup('lsp', { clear = true })
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
pattern = '*',
|
||||
|
@ -60,6 +60,9 @@ local function get_mode()
|
||||
return current_mode.name
|
||||
end
|
||||
|
||||
-- Display cusor line/total and column
|
||||
local position = '# ☰ %l/%L %2c '
|
||||
|
||||
-- Construct a statusline for special buffer types.
|
||||
local function special(group, name, title)
|
||||
-- Display current mode with dynamic highlights.
|
||||
@ -67,7 +70,7 @@ local function special(group, name, title)
|
||||
-- Display filename with dark highlights.
|
||||
line = line .. '%#StatusLineDark# ' .. title
|
||||
-- Display current/total lines and column with dynamic highlights.
|
||||
line = line .. '%=' .. '%#' .. group .. '# ☰%l/%L ·%2c '
|
||||
line = line .. '%=' .. '%#' .. group .. position
|
||||
-- Combine the elements into a single string to be evaluated.
|
||||
return line
|
||||
end
|
||||
@ -100,7 +103,7 @@ local function generic(group, name, show_lsp)
|
||||
'%{&fileencoding ==# "utf-8" ? "" : &fileencoding}' ..
|
||||
'%{&fileformat ==# "unix" ? "" : "[".&fileformat."]"}' .. ' %)'
|
||||
-- Display current/total lines and column with dynamic highlights.
|
||||
line = line .. '%#' .. group .. '# ☰ %l/%L %2c '
|
||||
line = line .. '%#' .. group .. position
|
||||
-- Combine the elements into a single string to be evaluated.
|
||||
return line
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user