summaryrefslogtreecommitdiffstats
path: root/vim.nix
blob: 0e81b049eb54f0a53a18069c231124f1f8d0a0c9 (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
{ config, pkgs, ... }:
{

  environment.systemPackages = with pkgs; [
    (lib.lowPrio pkgs.vim-full) # Lower Vim's priority
    (pkgs.writeShellApplication {
      name = "vi";
      runtimeInputs = [ pkgs.nvi ];
      text = ''
        exec ${pkgs.nvi}/bin/vi "$@"
      '';
    })
  ];

  environment.etc."vimrc".text = ''
    set autoread
    au FocusGained,BufEnter * silent! checktime

    " :W sudo saves the file
    " (useful for handling the permission-denied error)
    command! W execute 'w !sudo tee % > /dev/null' <bar> edit!

    " Turn on the Wild menu
    set wildmenu

    " Ignore compiled files
    set wildignore=*.o,*~,*.pyc
    set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store


    set ruler

    set ignorecase
    set smartcase
    set hlsearch
    set incsearch
    set lazyredraw
    set magic
    set showmatch

    syntax enable
    set noswapfile

    " Use spaces instead of tabs
    set expandtab

    " Be smart when using tabs ;)
    set smarttab

    " 1 tab == 4 spaces
    set shiftwidth=4
    set tabstop=4

    " Linebreak on 500 characters
    set lbr
    set tw=500

    set ai "Auto indent
    set si "Smart indent
    set wrap "Wrap lines

    " Always show the status line
    set laststatus=2

    set number relativenumber


      " Force the cursor to a Block when Vim starts
    let &t_ti = &t_ti . "\e[2 q"
    let &t_te = &t_te . "\e[2 q"
    let &t_EI = "\e[2 q"
    let &t_SI = "\e[2 q"
  '';

  programs.neovim = {
    enable = true;
    defaultEditor = true;
    configure = {
      customRC = ''

        set autoread
        au FocusGained,BufEnter * silent! checktime

        " :W sudo saves the file
        " (useful for handling the permission-denied error)
        command! W execute 'w !sudo tee % > /dev/null' <bar> edit!

        " Turn on the Wild menu
        set wildmenu

        " Ignore compiled files
        set wildignore=*.o,*~,*.pyc
        set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store


        set ruler

        set ignorecase
        set smartcase
        set hlsearch
        set incsearch
        set lazyredraw
        set magic
        set showmatch

        syntax enable
        set noswapfile

        " Use spaces instead of tabs
        set expandtab

        " Be smart when using tabs ;)
        set smarttab

        " 1 tab == 4 spaces
        set shiftwidth=4
        set tabstop=4

        " Linebreak on 500 characters
        set lbr
        set tw=500

        set ai "Auto indent
        set si "Smart indent
        set wrap "Wrap lines

        " Always show the status line
        set laststatus=2

        set number relativenumber

      '';
    };
  };

}