From a7215fa101160c6167568903fb4191163b7fbe73 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Tue, 26 Apr 2022 11:31:50 +0200 Subject: [PATCH 1/3] neovim: add template for shell.nix files --- modules/terminal-life/nvim/lsp.vim | 8 ++++++++ profiles/base-user/home.nix | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/modules/terminal-life/nvim/lsp.vim b/modules/terminal-life/nvim/lsp.vim index 1b4a4d31..2c132414 100644 --- a/modules/terminal-life/nvim/lsp.vim +++ b/modules/terminal-life/nvim/lsp.vim @@ -8,6 +8,14 @@ set completeopt=menuone,noinsert,noselect " Avoid showing extra messages when using completion set shortmess+=c +function AddTemplate(tmpl_file) + exe "0read " . a:tmpl_file + set nomodified + 6 +endfunction + +autocmd BufNewFile shell.nix call AddTemplate("$XDG_DATA_HOME/nvim/templates/shell.nix.tmpl") + " Configure neovim 0.6+ experimental LSPs " https://github.com/neovim/nvim-lspconfig " https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md diff --git a/profiles/base-user/home.nix b/profiles/base-user/home.nix index 4becfab3..0736b6d4 100644 --- a/profiles/base-user/home.nix +++ b/profiles/base-user/home.nix @@ -54,6 +54,20 @@ in # Ensure nvim backup directory gets created # Workaround for E510: Can't make backup file (add ! to override) xdg.dataFile."nvim/backup/.keep".text = ""; + xdg.dataFile."nvim/templates/.keep".text = ""; + xdg.dataFile."shell.nix.tmpl" = { + text = '' + let + unstable = import (fetchTarball https://github.com/nixos/nixpkgs/archive/nixos-unstable.tar.gz) { }; + in + { nixpkgs ? import {} }: + with nixpkgs; mkShell { + buildInputs = [ + ]; + } + ''; + target = "nvim/templates/shell.nix.tmpl"; + }; # Allow unfree packages only on a user basis, not on a system-wide basis xdg.configFile."nixpkgs/config.nix".text = " { allowUnfree = true; } "; From af67e0d15f87399c14fb6e165a1d460d38a4a933 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Sat, 30 Apr 2022 15:12:26 +0200 Subject: [PATCH 2/3] neovim: don't show diagnostics when in insert mode --- modules/terminal-life/nvim/lsp.vim | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/modules/terminal-life/nvim/lsp.vim b/modules/terminal-life/nvim/lsp.vim index 2c132414..10231631 100644 --- a/modules/terminal-life/nvim/lsp.vim +++ b/modules/terminal-life/nvim/lsp.vim @@ -54,6 +54,22 @@ lua <ca', 'lua vim.lsp.buf.code_action()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) + -- Show diagnostic popup on cursor hold + vim.api.nvim_create_autocmd("CursorHold", { + buffer = bufnr, + callback = function() + local opts = { + focusable = false, + close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, + border = 'rounded', + source = 'always', + prefix = ' ', + scope = 'cursor', + } + vim.diagnostic.open_float(nil, opts) + end + }) + end -- Add additional capabilities supported by nvim-cmp @@ -198,8 +214,7 @@ for type, icon in pairs(signs) do end EOF -" Show diagnostic popup on cursor hold -autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, { focus = false, scope = "cursor" }) +"autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focus = false, scope = "cursor" }) " have a fixed column for the diagnostics to appear in " this removes the jitter when warnings/errors flow in From ed26820593f402aab306a70ef70c10524822fcb5 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Sat, 30 Apr 2022 18:11:43 +0200 Subject: [PATCH 3/3] neovim: remove unneeded autocmd CursorHold --- modules/terminal-life/nvim/lsp.vim | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/terminal-life/nvim/lsp.vim b/modules/terminal-life/nvim/lsp.vim index 10231631..35c065a6 100644 --- a/modules/terminal-life/nvim/lsp.vim +++ b/modules/terminal-life/nvim/lsp.vim @@ -214,8 +214,6 @@ for type, icon in pairs(signs) do end EOF -"autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focus = false, scope = "cursor" }) - " have a fixed column for the diagnostics to appear in " this removes the jitter when warnings/errors flow in set signcolumn=yes:2