Setup shfmt in nvim
[khome.git] / home / .config / nvim / init.vim
CommitLineData
e66a0080
SK
1"==============================================================================
2" Plugins
3"==============================================================================
4
e2c73814
SK
5" Alternative plugin managers to try:
6" - https://github.com/Shougo/dein.vim
7
e66a0080
SK
8" BEGIN Vim-Plug (https://github.com/junegunn/vim-plug)
9" Run :PlugInstall after adding a new plugin
10call plug#begin()
11
834da58b 12Plug 'z0mbix/vim-shfmt', { 'for': 'sh' }
e66a0080
SK
13Plug 'dense-analysis/ale' " Syntastic's spiritual succesor
14Plug 'preservim/nerdtree'
15"Plug 'nvim-tree/nvim-web-devicons' " Needs patched fonts: https://www.nerdfonts.com/
16Plug 'phha/zenburn.nvim'
17Plug 'itchyny/lightline.vim'
18Plug 'numToStr/Comment.nvim'
19Plug 'rust-lang/rust.vim'
20Plug '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
34call plug#end()
35" END Vim-Plug
36
37lua require('Comment').setup()
38" luafile ~/.config/nvim/setup-rust-tools.lua
39"luafile ~/.config/nvim/setup-lsp-rust-jonhoo.lua
40source ~/.config/nvim/setup-coc.vim
41
42" NERDTree
43let NERDTreeShowLineNumbers=1
44
dfa253a2
SK
45" rust.vim
46let g:rustfmt_autosave = 1
47
834da58b
SK
48" shfmt
49let 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
e66a0080
SK
52"==============================================================================
53" Defaults
54"==============================================================================
55
56"------------------------------------------------------------------------------
57" General
58"------------------------------------------------------------------------------
59set nocompatible " Because plain vi is a bit annoying
60set nu " Line numbers in gutter
61"set rnu " Relative number. relativenumber rnu norelativenumber nornu
62set ruler " Line and column numbers in status
63set splitright splitbelow " Split window order
64set bs=2 " Enable backspace key
65set history=1000 " Bump history from default of 20
66set modeline
67set modelines=3
68set ttimeoutlen=100 " Reduce delay when addinng libe above ("O")
69"set fileformats=unix
70filetype on
71filetype plugin on
72set mouse=a " To scroll Coc tooltips. https://github.com/neoclide/coc.nvim/issues/1405
73set spellfile=~/.vim/spell/en.utf-8.add
74set spelllang=en,ru
75
76" lightline
77set laststatus=2
78set noshowmode
79let g:lightline = {'colorscheme': 'seoul256'}
80
81"------------------------------------------------------------------------------
82" Color
83"------------------------------------------------------------------------------
3dab95b2
SK
84set t_Co=256
85syntax enable
86set background=dark
87colorscheme zenburn
e66a0080
SK
88
89au 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"------------------------------------------------------------------------------
97set hlsearch
98set incsearch
99set noignorecase
100set smartcase
101
102"------------------------------------------------------------------------------
103" Text format / indentation
104"------------------------------------------------------------------------------
105filetype indent on
106set autoindent
107set smartindent
108set expandtab
109set tabstop=8
110set softtabstop=4
111set shiftwidth=4
112set textwidth=0 " What is the point of this again? Prevent auto-wrapping?
113
114"------------------------------------------------------------------------------
115" Code folding
116"------------------------------------------------------------------------------
117set foldmethod=indent
118set nofoldenable
119
120"------------------------------------------------------------------------------
121" Style enforcement
122"------------------------------------------------------------------------------
123" Lines too-long
3dab95b2 124let &colorcolumn=join(range(80,80),",")
e66a0080
SK
125"match ErrorMsg '\%>79v.\+'
126
3dab95b2 127match ErrorMsg '\s\+$' " Trailing whitespace
e66a0080
SK
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
137autocmd FileType c set noexpandtab | set shiftwidth=8 | set tabstop=8 | set softtabstop=8
138
139" TypeScript
140autocmd FileType typescript set noexpandtab | set shiftwidth=8 | set tabstop=8 | set softtabstop=8
141
142" R
143autocmd FileType r set tabstop=2 | set softtabstop=2 | set shiftwidth=2
144
145" Python
146autocmd FileType python set omnifunc=pythoncomplete#Complete
147
148" Git commit
149autocmd FileType gitcommit set spell
150
151" Markdown
152"autocmd FileType markdown set spell
153autocmd FileType markdown set expandtab | set tabstop=2 | set softtabstop=2 | set shiftwidth=2
154
155" HTML
156autocmd FileType html set spell
157
158" MediaWiki
159autocmd FileType mediawiki set spell
160autocmd FileType mediawiki set tabstop=2 | set softtabstop=2 | set shiftwidth=2
161
162" Tiger
163autocmd BufNewFile,BufRead *.tig set filetype=tiger
164
165" SML
166autocmd BufNewFile,BufRead *.sig set filetype=sml
167
168" Mathematica
169autocmd BufNewFile,BufRead *.m set filetype=mma
170autocmd BufNewFile,BufRead *.mt set filetype=mma
171autocmd FileType mma set tabstop=2 | set softtabstop=2 | set shiftwidth=2
172
173" F#
174autocmd FileType fsharp set tabstop=4 | set softtabstop=4 | set shiftwidth=4
175
176" twtxt.txt
177autocmd BufNewFile,BufRead twtxt.txt set filetype=conf | set noexpandtab
178
179" Scheme
180autocmd FileType scheme set tabstop=2 | set softtabstop=2 | set shiftwidth=2
181
182" Racket
183autocmd FileType racket setlocal equalprg=scmindent.rkt
184"autocmd FileType racket setlocal equalprg=raco\ fmt
185
186" Erlang
187"autocmd FileType erlang setlocal equalprg=erlfmt
188autocmd 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" -----------------------------------------------------------------------------
200let g:syntastic_enable_racket_racket_checker = 0
201
202" -----------------------------------------------------------------------------
203" OCaml
204" -----------------------------------------------------------------------------
205autocmd FileType ocaml set tabstop=2 | set softtabstop=2 | set shiftwidth=2
This page took 0.084872 seconds and 4 git commands to generate.