Run rustfmt on .rs file write
[khome.git] / home / .config / nvim / init.vim
1 "==============================================================================
2 " Plugins
3 "==============================================================================
4
5 " BEGIN Vim-Plug (https://github.com/junegunn/vim-plug)
6 " Run :PlugInstall after adding a new plugin
7 call plug#begin()
8
9 Plug 'dense-analysis/ale' " Syntastic's spiritual succesor
10 Plug 'preservim/nerdtree'
11 "Plug 'nvim-tree/nvim-web-devicons' " Needs patched fonts: https://www.nerdfonts.com/
12 Plug 'phha/zenburn.nvim'
13 Plug 'itchyny/lightline.vim'
14 Plug 'numToStr/Comment.nvim'
15 Plug 'rust-lang/rust.vim'
16 Plug 'neoclide/coc.nvim', {'branch': 'release'}
17 " Plug 'neovim/nvim-lspconfig'
18
19 " Plug 'hrsh7th/cmp-nvim-lsp', {'branch': 'main'}
20 " Plug 'hrsh7th/cmp-buffer', {'branch': 'main'}
21 " Plug 'hrsh7th/cmp-path', {'branch': 'main'}
22 " Plug 'hrsh7th/nvim-cmp', {'branch': 'main'}
23 "
24 " " Only because nvim-cmp _requires_ snippets
25 " Plug 'hrsh7th/cmp-vsnip', {'branch': 'main'}
26 " Plug 'hrsh7th/vim-vsnip'
27
28 " Plug 'simrat39/rust-tools.nvim'
29
30 call plug#end()
31 " END Vim-Plug
32
33 lua require('Comment').setup()
34 " luafile ~/.config/nvim/setup-rust-tools.lua
35 "luafile ~/.config/nvim/setup-lsp-rust-jonhoo.lua
36 source ~/.config/nvim/setup-coc.vim
37
38 " NERDTree
39 let NERDTreeShowLineNumbers=1
40
41 " rust.vim
42 let g:rustfmt_autosave = 1
43
44 "==============================================================================
45 " Defaults
46 "==============================================================================
47
48 "------------------------------------------------------------------------------
49 " General
50 "------------------------------------------------------------------------------
51 set nocompatible " Because plain vi is a bit annoying
52 set nu " Line numbers in gutter
53 "set rnu " Relative number. relativenumber rnu norelativenumber nornu
54 set ruler " Line and column numbers in status
55 set splitright splitbelow " Split window order
56 set bs=2 " Enable backspace key
57 set history=1000 " Bump history from default of 20
58 set modeline
59 set modelines=3
60 set ttimeoutlen=100 " Reduce delay when addinng libe above ("O")
61 "set fileformats=unix
62 filetype on
63 filetype plugin on
64 set mouse=a " To scroll Coc tooltips. https://github.com/neoclide/coc.nvim/issues/1405
65 set spellfile=~/.vim/spell/en.utf-8.add
66 set spelllang=en,ru
67
68 " lightline
69 set laststatus=2
70 set noshowmode
71 let g:lightline = {'colorscheme': 'seoul256'}
72
73 "------------------------------------------------------------------------------
74 " Color
75 "------------------------------------------------------------------------------
76 set t_Co=256
77 syntax enable
78 set background=dark
79 colorscheme zenburn
80
81 au TextYankPost * lua vim.highlight.on_yank {higroup="IncSearch", timeout=250, on_visual=true, on_macro=true}
82
83 "hi Normal guibg=NONE " Transparency
84 "hi Normal ctermbg=NONE " Transparency
85
86 "------------------------------------------------------------------------------
87 " Search
88 "------------------------------------------------------------------------------
89 set hlsearch
90 set incsearch
91 set noignorecase
92 set smartcase
93
94 "------------------------------------------------------------------------------
95 " Text format / indentation
96 "------------------------------------------------------------------------------
97 filetype indent on
98 set autoindent
99 set smartindent
100 set expandtab
101 set tabstop=8
102 set softtabstop=4
103 set shiftwidth=4
104 set textwidth=0 " What is the point of this again? Prevent auto-wrapping?
105
106 "------------------------------------------------------------------------------
107 " Code folding
108 "------------------------------------------------------------------------------
109 set foldmethod=indent
110 set nofoldenable
111
112 "------------------------------------------------------------------------------
113 " Style enforcement
114 "------------------------------------------------------------------------------
115 " Lines too-long
116 let &colorcolumn=join(range(80,80),",")
117 "match ErrorMsg '\%>79v.\+'
118
119 match ErrorMsg '\s\+$' " Trailing whitespace
120 "2match ErrorMsg '\t' " Tabs
121
122 " TODO: How to match more than 2 things? 3match is reserved for brackets.
123
124 "==============================================================================
125 " Per FileType overrides
126 "==============================================================================
127
128 " C
129 autocmd FileType c set noexpandtab | set shiftwidth=8 | set tabstop=8 | set softtabstop=8
130
131 " TypeScript
132 autocmd FileType typescript set noexpandtab | set shiftwidth=8 | set tabstop=8 | set softtabstop=8
133
134 " R
135 autocmd FileType r set tabstop=2 | set softtabstop=2 | set shiftwidth=2
136
137 " Python
138 autocmd FileType python set omnifunc=pythoncomplete#Complete
139
140 " Git commit
141 autocmd FileType gitcommit set spell
142
143 " Markdown
144 "autocmd FileType markdown set spell
145 autocmd FileType markdown set expandtab | set tabstop=2 | set softtabstop=2 | set shiftwidth=2
146
147 " HTML
148 autocmd FileType html set spell
149
150 " MediaWiki
151 autocmd FileType mediawiki set spell
152 autocmd FileType mediawiki set tabstop=2 | set softtabstop=2 | set shiftwidth=2
153
154 " Tiger
155 autocmd BufNewFile,BufRead *.tig set filetype=tiger
156
157 " SML
158 autocmd BufNewFile,BufRead *.sig set filetype=sml
159
160 " Mathematica
161 autocmd BufNewFile,BufRead *.m set filetype=mma
162 autocmd BufNewFile,BufRead *.mt set filetype=mma
163 autocmd FileType mma set tabstop=2 | set softtabstop=2 | set shiftwidth=2
164
165 " F#
166 autocmd FileType fsharp set tabstop=4 | set softtabstop=4 | set shiftwidth=4
167
168 " twtxt.txt
169 autocmd BufNewFile,BufRead twtxt.txt set filetype=conf | set noexpandtab
170
171 " Scheme
172 autocmd FileType scheme set tabstop=2 | set softtabstop=2 | set shiftwidth=2
173
174 " Racket
175 autocmd FileType racket setlocal equalprg=scmindent.rkt
176 "autocmd FileType racket setlocal equalprg=raco\ fmt
177
178 " Erlang
179 "autocmd FileType erlang setlocal equalprg=erlfmt
180 autocmd FileType erlang set tabstop=4 | set softtabstop=4 | set shiftwidth=4
181
182 " -----------------------------------------------------------------------------
183 " TypeScript
184 " -----------------------------------------------------------------------------
185 "let g:tsuquyomi_completion_detail = 1
186 "let g:tsuquyomi_use_local_typescript = 0
187 "let g:syntastic_typescript_checkers = ['tsuquyomi']
188
189 " -----------------------------------------------------------------------------
190 " Racket
191 " -----------------------------------------------------------------------------
192 let g:syntastic_enable_racket_racket_checker = 0
193
194 " -----------------------------------------------------------------------------
195 " OCaml
196 " -----------------------------------------------------------------------------
197 autocmd FileType ocaml set tabstop=2 | set softtabstop=2 | set shiftwidth=2
This page took 0.075202 seconds and 4 git commands to generate.