aboutsummaryrefslogtreecommitdiffstats
path: root/home/dev/neovim.nix
blob: 37bdaea03f12329b0bde6381bc136339b38f5bb7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{pkgs, ...}: {
  programs.neovim = {
    enable = true;
    defaultEditor = true;
    viAlias = true;
    vimAlias = true;
    coc.enable = true;
    plugins = with pkgs.vimPlugins; [
      NeoSolarized
      copilot-vim
      fzf-vim
      nerdcommenter
      vim-airline
      vim-airline-themes
      vim-go
      vim-sleuth
      vim-surround
      {
        plugin = undotree;
        config = ''
          nnoremap <F5> :UndotreeToggle<CR>
          if has("persistent_undo")
            let target_path = expand('~/.local/nvim-undo')
            if !isdirectory(target_path)
              call mkdir(target_path, "p", 0700)
            endif
            let &undodir=target_path
            set undofile
          endif
        '';
      }
    ];
    extraConfig = ''
      filetype off
      set nocompatible
      set modelines=0
      set encoding=utf-8
      set scrolloff=3
      set wildmode=list:longest
      set visualbell
      set backspace=indent,eol,start
      set laststatus=2
      set number
      set history=1000
      set title
      set ignorecase
      set smartcase
      set gdefault
      set incsearch
      set showmatch
      set hlsearch

      let mapleader = ","
      nmap <silent> <leader><space> :silent :nohlsearch<CR>

      set wrap
      set textwidth=0
      set list
      set listchars=tab:▸\ ,eol:¬
      set mousehide
      set mouse=a
      set cursorline
      set cursorcolumn

      au VimResized * exe "normal! \<c-w>="

      augroup vimrc_autocmd
        autocmd!

        " jump to the last position when reopening a file
        autocmd BufReadPost *
          \ if line("'\"") > 1 && line("'\"") <= line("$") |
          \   exe "normal! g`\"" |
          \ endif
      augroup END

      syn on
      set background=dark
      colorscheme NeoSolarized
    '';
  };
}