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