1
0
Fork 0

nvim: misc

This commit is contained in:
Vladimír Dudr 2023-06-23 09:28:12 +02:00
parent e1a597ec12
commit 5797583939
4 changed files with 37 additions and 3 deletions

View file

@ -60,6 +60,7 @@ function M.setup()
.. '%( │  %{get(b:,"gitsigns_head","")}%)' -- branch
.. ' │  %<%f%( [%M%R%W]%)' -- filename and modification flags
.. '%=' -- rest is right
.. '%( [%{get(b:,"attached_lsps","")}] | %)' -- branch
.. '%y ' -- filetype
.. '%-7.(%3.l:%-3.(%c%V%)%) %P' -- ruler

View file

@ -1,5 +1,6 @@
local server_configs = function()
return {
ansiblels = {},
powershell_es = {},
gopls = {},
clangd = {},
@ -7,7 +8,6 @@ local server_configs = function()
-- hls = {},
tsserver = {},
-- perlls = {},
rust_analyzer = {},
cssls = {},
html = {},
lemminx = {
@ -130,6 +130,15 @@ local function navic_attach(client, bufnr)
})
end
local function update_attached(bufnr)
local attached = '';
for _, client in pairs(vim.lsp.get_active_clients({ bufnr = bufnr })) do
attached = attached .. ',' .. client.name
end
vim.b[bufnr].attached_lsps = attached
end
local function on_attach(args) -- {{{
local bufnr = args.buf
@ -283,6 +292,9 @@ local function on_attach(args) -- {{{
},
}
end
update_attached(bufnr)
end -- }}}
local function make_client_capabilities()
@ -297,6 +309,12 @@ local function config()
vim.api.nvim_create_autocmd('LspAttach', {
callback = on_attach,
})
vim.api.nvim_create_autocmd('LspDetach', {
callback = function(ev)
vim.print(ev)
update_attached(ev.buf)
end,
})
local capabilities = make_client_capabilities()
@ -305,7 +323,7 @@ local function config()
nvim_lsp.util.default_config = vim.tbl_extend('force',
nvim_lsp.util.default_config,
{
capabilities = capabilities
capabilities = capabilities,
}
)
@ -352,6 +370,11 @@ return {
dependencies = { 'williamboman/mason.nvim' },
config = config_mason_lsp,
},
{
'simrat39/rust-tools.nvim',
build = ':MasonInstall rust-analyzer',
config = true,
},
},
keys = {
{ '<leader>li', '<Cmd>LspInfo<CR>', desc = 'Lsp info' },

View file

@ -236,7 +236,7 @@ return {
{ '<Leader>tt', '<Cmd>TroubleToggle<CR>', desc = 'Trouble toggle' },
{ '<Leader>td', '<Cmd>Trouble document_diagnostics<CR>', desc = 'Trouble toggle' },
},
config = {
opts = {
mode = 'document_diagnostics',
signs = {
-- icons / text used for a diagnostic

View file

@ -50,6 +50,15 @@ local M = {
-- }}}
}
function M.init()
local aug = vim.api.nvim_create_augroup('treesitterUpdate', { clear = true })
vim.api.nvim_create_autocmd('User', {
pattern = { 'LazySync' },
group = aug,
command = 'TSUpdate',
})
end
function M.config()
local ts_parsers = require 'nvim-treesitter.parsers'.get_parser_configs()
ts_parsers.xml = {
@ -72,6 +81,7 @@ function M.config()
},
}
require 'nvim-treesitter.configs'.setup {
ensure_installed = 'all', -- one of "all", "maintained" (parsers with maintainers), or a list of languages
sync_install = false,