nix-configs

Personal NixOS and home-manager configuration files
Log | Files | Refs

neovim.nix (1430B)


      1 { pkgs, ... }:
      2 
      3 {
      4   programs.neovim = {
      5     enable = true;
      6     withPython3 = false;
      7     withRuby = false;
      8     defaultEditor = true;
      9     plugins = with pkgs.vimPlugins; [ vim-nix ];
     10     extraConfig = ''
     11       set smartcase
     12       set nocompatible
     13       let mapleader =","
     14       set backspace=indent,eol,start
     15       set clipboard+=unnamedplus
     16       set ignorecase
     17       set linebreak
     18       set mouse=a
     19       set nohlsearch
     20       set number
     21       set title
     22       set titlestring=%f\ %m
     23       set whichwrap+=<,>,h,l,[,]
     24       set list listchars=nbsp:¬,tab:»·,trail:·,extends:>
     25       set shiftwidth=2
     26       set softtabstop=2
     27       set tabstop=2
     28       syntax on
     29       map <C-H> <C-W>
     30       map <C-Del> X<Esc>ce<del>
     31       map <F8> :setlocal spell! spelllang=en_gb<CR>
     32       xnoremap <A-z> :s/^.<CR>gv " alt-z removes first character of line
     33       nnoremap <A-z> 0x " alt-z in normal mode removes first char
     34       :iab <expr> _date strftime("%F")
     35       :iab <expr> _time strftime("%H:%M")
     36       :iab <expr> _stamp strftime("%F\T%H:%M:00")
     37       autocmd BufWritePre * %s/\s\+$//e
     38       autocmd BufWritepre * %s/\n\+\%$//e
     39       lua << EOF
     40     '';
     41     initLua = ''
     42       vim.api.nvim_create_user_command("Uppercase", function()
     43         vim.cmd("'<,'>s/.*/\\U&/")
     44       end, { range = true })
     45       vim.api.nvim_create_user_command("Lowercase", function()
     46         vim.cmd("'<,'>s/.*/\\L&/")
     47       end, { range = true })
     48       '';
     49   };
     50 }