From a613894008112d47f5926fe93f021c097a143fbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Fernando=20Carri=C3=B3n?= Date: Sat, 19 Oct 2024 13:18:31 +0200 Subject: [PATCH] fix nvim diagnostics --- etc/any/bash/bashrc.d/aliases.sh | 30 ++++++------- home/any/bash/.bash_aliases | 9 ++++ home/any/neovim.dirs | 6 +-- .../nvim/after/queries/python/highlights.scm | 15 +++++++ .../.config/nvim/lua/crthaze/diagnostics.lua | 44 +++++++++++++++++++ .../.config/nvim/lua/crthaze/lazy/lsp.lua | 16 ++++++- 6 files changed, 99 insertions(+), 21 deletions(-) create mode 100644 home/any/neovim/.config/nvim/after/queries/python/highlights.scm create mode 100644 home/any/neovim/.config/nvim/lua/crthaze/diagnostics.lua diff --git a/etc/any/bash/bashrc.d/aliases.sh b/etc/any/bash/bashrc.d/aliases.sh index 7b910ea..fa34c63 100644 --- a/etc/any/bash/bashrc.d/aliases.sh +++ b/etc/any/bash/bashrc.d/aliases.sh @@ -18,21 +18,21 @@ fi # Editors alias ed="ed -p': '" -if [ -x "$(command -v nvim)" ] && ! limited_terminal -then - vim_path="$(command -v vim)" - vimdiff_path="$(command -v vimdiff)" - if [ -x "$vim_path" ] - then - alias vvim="$vim_path" - fi - if [ -x "$vimdiff_path" ] - then - alias vvimdiff="$vimdiff_path" - fi - alias vim=nvim - alias vimdiff="nvim -d" -fi +# if [ -x "$(command -v nvim)" ] && ! limited_terminal +# then +# vim_path="$(command -v vim)" +# vimdiff_path="$(command -v vimdiff)" +# if [ -x "$vim_path" ] +# then +# alias vvim="$vim_path" +# fi +# if [ -x "$vimdiff_path" ] +# then +# alias vvimdiff="$vimdiff_path" +# fi +# alias vim=nvim +# alias vimdiff="nvim -d" +# fi if [[ "$(whence -b vi)" == "/usr/local/bin/ex" ]] then alias vi='EXINIT="$(inline_exrc $HOME/.exrc)" vi' diff --git a/home/any/bash/.bash_aliases b/home/any/bash/.bash_aliases index c6d60a7..a879c88 100644 --- a/home/any/bash/.bash_aliases +++ b/home/any/bash/.bash_aliases @@ -32,6 +32,10 @@ alias k=kubectl if [ -x "$(command -v neomutt)" ] then + if [ -x "$(command -v mutt)" ] + then + alias mmutt=mutt + fi alias mutt=neomutt fi @@ -64,6 +68,11 @@ then alias title='wezterm cli set-tab-title' fi +if [ -x "$(command -v lazygit)" ] +then + alias lg=lazygit +fi + # Local if [ -f ~/.bash_aliases.local ] then diff --git a/home/any/neovim.dirs b/home/any/neovim.dirs index 149f8e0..fbe924d 100644 --- a/home/any/neovim.dirs +++ b/home/any/neovim.dirs @@ -1,6 +1,2 @@ -.config/nvim/autoload -.config/nvim/colors -.config/nvim/plugged -.config/nvim/session -.config/nvim/spell .var/tmp/nvim/ +.config/nvim/after/queries/python diff --git a/home/any/neovim/.config/nvim/after/queries/python/highlights.scm b/home/any/neovim/.config/nvim/after/queries/python/highlights.scm new file mode 100644 index 0000000..2ea69e0 --- /dev/null +++ b/home/any/neovim/.config/nvim/after/queries/python/highlights.scm @@ -0,0 +1,15 @@ +; extends + +; Module docstring +(module . (expression_statement (string) @comment)) + +; Class docstring +(class_definition + body: (block . (expression_statement (string) @comment))) + +; Function/method docstring +(function_definition + body: (block . (expression_statement (string) @comment))) + +; Attribute docstring +((expression_statement (assignment)) . (expression_statement (string) @comment)) diff --git a/home/any/neovim/.config/nvim/lua/crthaze/diagnostics.lua b/home/any/neovim/.config/nvim/lua/crthaze/diagnostics.lua new file mode 100644 index 0000000..770930b --- /dev/null +++ b/home/any/neovim/.config/nvim/lua/crthaze/diagnostics.lua @@ -0,0 +1,44 @@ +vim.diagnostic.config({ + virtual_text = false, + float = { + focusable = false, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + signs = true, + underline = true, + update_in_insert = true, + severity_sort = false, +}) + +-- Function to check if a floating dialog exists and if not +-- then check for diagnostics under the cursor +function OpenDiagnosticIfNoFloat() + for _, winid in pairs(vim.api.nvim_tabpage_list_wins(0)) do + if vim.api.nvim_win_get_config(winid).zindex then + return + end + end + -- THIS IS FOR BUILTIN LSP + vim.diagnostic.open_float(0, { + scope = "cursor", + focusable = false, + close_events = { + "CursorMoved", + "CursorMovedI", + "BufHidden", + "InsertCharPre", + "WinLeave", + }, + }) +end +-- Show diagnostics under the cursor when holding position +vim.api.nvim_create_augroup("lsp_diagnostics_hold", { clear = true }) +vim.api.nvim_create_autocmd({ "CursorHold" }, { + pattern = "*", + command = "lua OpenDiagnosticIfNoFloat()", + group = "lsp_diagnostics_hold", +}) diff --git a/home/any/neovim/.config/nvim/lua/crthaze/lazy/lsp.lua b/home/any/neovim/.config/nvim/lua/crthaze/lazy/lsp.lua index 471fda3..43f979d 100644 --- a/home/any/neovim/.config/nvim/lua/crthaze/lazy/lsp.lua +++ b/home/any/neovim/.config/nvim/lua/crthaze/lazy/lsp.lua @@ -11,6 +11,7 @@ return { "L3MON4D3/LuaSnip", "saadparwaiz1/cmp_luasnip", "j-hui/fidget.nvim", + "towolf/vim-helm", }, config = function() @@ -120,7 +121,20 @@ return { } } } - end + end, + helm_ls = function() + local lspconfig = require('lspconfig') + lspconfig.helm_ls.setup { + settings = { + ['helm-ls'] = { + yamlls = { + enabled = false, + -- path = "yaml-language-server", + } + } + } + } + end, } })