From e1378a36178adb2b1ea7d73b4cde0b7412f6bf29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Fri, 18 Aug 2023 16:39:03 +0300 Subject: [PATCH] start with vim --- hosts/vno1-oh2/configuration.nix | 9 ++-- modules/base/default.nix | 9 +--- modules/base/users/default.nix | 14 +++++ modules/base/users/vimrc | 91 ++++++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+), 11 deletions(-) create mode 100644 modules/base/users/vimrc diff --git a/hosts/vno1-oh2/configuration.nix b/hosts/vno1-oh2/configuration.nix index cffa8fd..dcaabfd 100644 --- a/hosts/vno1-oh2/configuration.nix +++ b/hosts/vno1-oh2/configuration.nix @@ -32,9 +32,12 @@ base = { zfs.enable = true; - users.passwd = { - root.passwordFile = config.age.secrets.root-passwd-hash.path; - motiejus.passwordFile = config.age.secrets.motiejus-passwd-hash.path; + users = { + installVimPlugins = true; + passwd = { + root.passwordFile = config.age.secrets.root-passwd-hash.path; + motiejus.passwordFile = config.age.secrets.motiejus-passwd-hash.path; + }; }; snapshot = { diff --git a/modules/base/default.nix b/modules/base/default.nix index 8f914b9..5ad8085 100644 --- a/modules/base/default.nix +++ b/modules/base/default.nix @@ -123,10 +123,6 @@ brotli zopfli ]; - - variables = { - EDITOR = "nvim"; - }; }; programs = { @@ -134,10 +130,7 @@ sysdig.enable = pkgs.stdenv.hostPlatform.system == "x86_64-linux"; - neovim = { - enable = true; - defaultEditor = true; - }; + vim.defaultEditor = true; }; services = { diff --git a/modules/base/users/default.nix b/modules/base/users/default.nix index b98a0b8..386b32a 100644 --- a/modules/base/users/default.nix +++ b/modules/base/users/default.nix @@ -6,6 +6,11 @@ ... }: { options.mj.base.users = with lib.types; { + installVimPlugins = lib.mkOption { + type = bool; + default = false; + }; + passwd = lib.mkOption { type = attrsOf (submodule ( {...}: { @@ -50,6 +55,15 @@ home-manager.users.motiejus = {pkgs, ...}: { home.stateVersion = "23.05"; programs.direnv.enable = true; + programs.vim = { + enable = true; + plugins = lib.mkIf config.mj.base.users.installVimPlugins [ + pkgs.vimPlugins.fugitive + pkgs.vimPlugins.vim-go + pkgs.vimPlugins.zig-vim + ]; + extraConfig = builtins.readFile ./vimrc; + }; programs.git = { enable = true; userEmail = "motiejus@jakstys.lt"; diff --git a/modules/base/users/vimrc b/modules/base/users/vimrc new file mode 100644 index 0000000..65778e1 --- /dev/null +++ b/modules/base/users/vimrc @@ -0,0 +1,91 @@ +if $VIM_PATH != "" + let $PATH = $VIM_PATH +endif + +syntax on +filetype plugin indent on +set et ts=4 sw=4 sts=4 nu hlsearch ruler ignorecase smartcase nomodeline bg=dark incsearch +set path=**/* grepprg=rg\ --vimgrep grepformat^=%f:%l:%c:%m backspace=2 nojs +set laststatus=1 +nnoremap \ gqj +command OLD :enew | setl buftype=nofile | 0put =v:oldfiles | nnoremap :e =getline('.') + +let g:gutentags_enabled = 0 +let g:gutentags_generate_on_new = 0 +let g:gutentags_cache_dir = '~/.vim/ctags' +let b:gutentags_file_list_command = 'git ls-files' + +call matchadd('ColorColumn', '\%81v', 100) +" thanks to drew de vault's vimrc, except swearing +set mouse=a +set backupdir=~/.cache directory=~/.cache +"nnoremap Q :grep +nmap gs :grep + +" bits from vim-sensible +set autoindent smarttab nrformats-=octal +nnoremap :nohlsearch=has('diff')?'diffupdate':'' +set wildmenu sidescrolloff=5 display+=lastline encoding=utf-8 +set formatoptions+=j history=1000 tabpagemax=50 sessionoptions-=options + +" so Gdiff and vimdiff output are somewhat readable +if &diff + syntax off +endif + +if has("patch-8.1-0360") + set diffopt+=algorithm:patience +endif + +"nmap gs :rg :grep + +" html +au FileType html,gohtmltmpl setlocal ts=2 sw=2 sts=2 + +" ruby +au BufRead,BufNewFile Vagrantfile setfiletype ruby + +" starlark +au BufRead,BufNewFile *.star setfiletype python + +" puppet +au BufRead,BufNewFile *.pp setfiletype puppet +au FileType puppet setlocal ts=2 sw=2 sts=2 syntax=ruby +au FileType puppet let g:gutentags_enabled = 1 +au FileType puppet let b:gutentags_file_list_command = 'git ls-files *.pp' +au FileType puppet nnoremap :call search('\s', 'b'):call search('\w')vE +"au FileType puppet nnoremap :call search('\s', 'b'):call search('\w'):call search('[^a-z:]\|$', 's')hv`' + +" puppet +au BufRead,BufNewFile *.j2 setfiletype django + +" avro +au BufRead,BufNewFile *.avsc setfiletype json +au BufRead,BufNewFile *.avsc setlocal ts=2 sw=2 sts=2 + +" redo +au BufRead,BufNewFile *.do setfiletype sh + +" go +au FileType go setlocal noet +au FileType go nnoremap :GoDef +au FileType go let g:go_template_autocreate = 0 +au FileType go let g:go_fmt_command = "goimports" + +" strace +au FileType strace setlocal nonu + +" yaml +au FileType yaml setlocal ts=2 sw=2 sts=2 + +" sql +au FileType sql setlocal formatprg=pg_format\ - +au FileType sql setlocal ts=2 sw=2 sts=2 +let g:loaded_sql_completion = 0 +let g:omni_sql_no_default_maps = 1 + +" mail +autocmd BufRead,BufNewFile *mutt-* setfiletype mail + +" TeX +au FileType tex setlocal spell spelllang=en_us ts=2 sw=2 sts=2