From 7f71eec03c8e561b9b1b88f4ca17f3db69404184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Thu, 2 Nov 2023 17:04:53 +0100 Subject: [PATCH] nix: Editor config Should have started there I guess. --- config/automatrop/roles/vim/handlers/main.yml | 11 -- .../automatrop/roles/vim/templates/editor.j2 | 101 ------------------ .../roles/vim/templates/init.vim.j2 | 15 --- config/nix/hm/common.nix | 2 +- config/nix/hm/vim.nix | 75 +++++++++++++ 5 files changed, 76 insertions(+), 128 deletions(-) delete mode 100644 config/automatrop/roles/vim/handlers/main.yml delete mode 100644 config/automatrop/roles/vim/templates/editor.j2 diff --git a/config/automatrop/roles/vim/handlers/main.yml b/config/automatrop/roles/vim/handlers/main.yml deleted file mode 100644 index e11ae85..0000000 --- a/config/automatrop/roles/vim/handlers/main.yml +++ /dev/null @@ -1,11 +0,0 @@ -- name: Upgrade Neovim plugins - command: "nvim +PlugUpgrade +PlugUpdate +PlugInstall +qall!" - listen: nvim plugins changed - environment: - VIMINIT: "source {{ ansible_user_dir }}/.config/nvim/plugininstall.vim" - -- name: Upgrade Vim plugins - command: "vim +PlugUpgrade +PlugUpdate +PlugInstall +qall!" - listen: vim plugins changed - environment: - VIMINIT: "source {{ ansible_user_dir }}/.config/vim/plugininstall.vim" diff --git a/config/automatrop/roles/vim/templates/editor.j2 b/config/automatrop/roles/vim/templates/editor.j2 deleted file mode 100644 index 0b77445..0000000 --- a/config/automatrop/roles/vim/templates/editor.j2 +++ /dev/null @@ -1,101 +0,0 @@ -" From https://www.hillelwayne.com/post/intermediate-vim/ - -set encoding=utf-8 -set title - -set number -set ruler -set wrap - -set scrolloff=10 - -set ignorecase -set smartcase -set gdefault -if has('nvim') - set inccommand=nosplit " Shows you in realtime what changes your ex command should make. -endif - -set incsearch - -set hlsearch - -set tabstop=4 -set shiftwidth=4 -set expandtab - -set visualbell -set noerrorbells - -set backspace=indent,eol,start - -set hidden -set updatetime=250 -set lazyredraw " Do not redraw screen in the middle of a macro. Makes them complete faster. - -set cursorcolumn - -set splitbelow - -" Turn off relativenumber only for insert mode. -if has('nvim') - set relativenumber - augroup every - autocmd! - au InsertEnter * set norelativenumber - au InsertLeave * set relativenumber - augroup END -endif - -" Keep undo history across sessions by storing it in a file -if has('persistent_undo') - let myUndoDir = expand(vimDir . '/undodir') - " Create dirs - call system('mkdir ' . myUndoDir) - let &undodir = myUndoDir - set undofile -endif - -syntax enable - -" From http://stackoverflow.com/a/5004785/2766106 -set list -set listchars=tab:╾╌,trail:·,extends:↦,precedes:↤,nbsp:_ -set showbreak=↪ - -filetype on -filetype plugin on -filetype indent on - -set wildmode=longest:full,full -set wildmenu -set showcmd - -" Completion - -" Avoid showing message extra message when using completion -set shortmess+=c - -" Close the file explorer once you select a file -let g:netrw_fastbrowse = 0 - -" Allow saving of files as sudo when I forgot to start vim using sudo. -" From https://stackoverflow.com/a/7078429 -cmap w!! w !sudo tee > /dev/null % - -imap jk -vmap - -nmap o -nmap :bp -nmap :bn -nmap kkkkkkkkkkkkkkkkkkkkk -nmap jjjjjjjjjjjjjjjjjjjjj - -" \s to replace globally the word under the cursor -nnoremap s :%s/\<\>/ - -" add extensions to syntax -au BufNewFile,BufRead *.jinja set filetype=jinja2 - -command Reload source $MYVIMRC diff --git a/config/automatrop/roles/vim/templates/init.vim.j2 b/config/automatrop/roles/vim/templates/init.vim.j2 index 63ecb4d..66e45b6 100644 --- a/config/automatrop/roles/vim/templates/init.vim.j2 +++ b/config/automatrop/roles/vim/templates/init.vim.j2 @@ -1,18 +1,3 @@ -set nocompatible -filetype on - -" SET PATHS - -set runtimepath+=~/.config/{{ variant }} -let vimDir = '$HOME/.cache/{{ variant }}' -call system('mkdir ' . vimDir) -let &runtimepath.=','.vimDir -set viminfo+=n~/.cache/{{ variant }}/viminfo - -" EDITOR CONFIGURATION - -{% include 'editor.j2' %} - " PLUGINS CONFIGURATION {% include 'pluginconfig.j2' %} diff --git a/config/nix/hm/common.nix b/config/nix/hm/common.nix index 0d5b816..017ed0f 100644 --- a/config/nix/hm/common.nix +++ b/config/nix/hm/common.nix @@ -21,7 +21,7 @@ # FIXME Still want this despite using nixvim gpg = { enable = true; - homedir = "${config.xdg.dataHome}/gnupg"; + homedir = "${config.xdg.stateHome}/gnupg"; settings = { # Remove fluff no-greeting = true; diff --git a/config/nix/hm/vim.nix b/config/nix/hm/vim.nix index 63c6729..5e98b6c 100644 --- a/config/nix/hm/vim.nix +++ b/config/nix/hm/vim.nix @@ -34,6 +34,40 @@ in programs.nixvim = { enable = true; + options = { + # From https://www.hillelwayne.com/post/intermediate-vim/ + title = true; + number = true; + relativenumber = true; + scrolloff = 10; + lazyredraw = true; # Do not redraw screen in the middle of a macro. Makes them complete faster. + cursorcolumn = true; + + ignorecase = true; + smartcase = true; + gdefault = true; + + tabstop = 4; + shiftwidth = 4; + expandtab = true; + + splitbelow = true; + visualbell = true; + + updatetime = 250; + undofile = true; + + # From http://stackoverflow.com/a/5004785/2766106 + list = true; + listchars = "tab:╾╌,trail:·,extends:↦,precedes:↤,nbsp:_"; + showbreak = "↪"; + + wildmode = "longest:full,full"; + wildmenu = true; + }; + globals = { + netrw_fastbrowse = 0; # Close the file explorer once you select a file + }; colorschemes.base16 = { # FIXME Dynamic... or use stylix enable = true; @@ -249,6 +283,15 @@ in ./vim/nvim-ts-rainbow.lua ]; extraConfigVim = '' + " GENERAL + + " Avoid showing message extra message when using completion + set shortmess+=c + + command Reload source $MYVIMRC + + " PLUGINS + " vim-gutentags let g:gutentags_cache_dir = expand('~/.cache/nvim/tags') @@ -273,12 +316,44 @@ in ''; autoCmd = [ + # Turn off relativenumber only for insert mode + { event = "InsertEnter *"; command = "set norelativenumber"; } + { event = "InsertLeave *"; command = "set relativenumber"; } + + # Additional extensions + { event = "BufNewFile,BufRead"; pattern = "*.jinja"; command = "set filetype=jinja2"; } # TODO Probably GH-specific? + # vim-easy-align: Align Markdown tables { event = "FileType markdown"; command = "vmap :EasyAlign*"; } ]; + userCommands = { + # Reload = { command = "source $MYVIRMC"; }; + # TODO Is not working, options is set to nil even though it shouldn't + }; + # 23.11: Use keymaps, seems better maps = { + # GENERAL + + # Allow saving of files as sudo when I forgot to start vim using sudo. + # From https://stackoverflow.com/a/7078429 + command."w!!" = { action = "w !sudo tee > /dev/null %"; }; + + insert."jk" = { action = ""; }; + visual."" = { action = ""; }; + normal."" = { action = "o"; }; + + # normal."" = { action = ":bp"; }; + # normal."" = { action = ":bn"; }; + normal."" = { action = "kkkkkkkkkkkkkkkkkkkkk"; }; + normal."" = { action = "jjjjjjjjjjjjjjjjjjjjj"; }; + + # \s to replace globally the word under the cursor + normal."s" = { action = ":%s/\\<\\>/"; }; + + # PLUGINS + # barbar normal."" = { action = "BufferPrevious"; silent = true; }; normal."" = { action = "BufferNext"; silent = true; };