From 03cf31989f3aaa6e1e252ed7d0a079cd1c102f97 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Tue, 26 Apr 2022 11:31:50 +0200 Subject: [PATCH] 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 d34929f8..e9d98812 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 19d2aaed..87db37dd 100644 --- a/profiles/base-user/home.nix +++ b/profiles/base-user/home.nix @@ -64,6 +64,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; } ";