aboutsummaryrefslogtreecommitdiff
path: root/config/nvim/init.vim
blob: 1d0e6c613cadadf1c90ea70d94add784c8171bef (plain)
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
137
138
augroup user_config
  autocmd!
  autocmd BufWritePost init.vim source <afile>
augroup end

lua require('plugins')
augroup packer_user_config
  autocmd!
  autocmd BufWritePost plugins.lua source <afile> | PackerCompile
augroup end


set exrc
set secure
set title

set hidden
set undofile
set undodir=~/.cache/nvim-undo//
set directory=$HOME/.cache/nvim//
set hlsearch
set wildmode=longest:full,full
set wildmenu
set modeline
set encoding=utf-8

set backspace=indent,eol,start
set completeopt=menu,menuone,preview,noselect,noinsert

colorscheme nord
let g:lightline = { 'colorscheme': 'nord' }

set number
set colorcolumn=80
set textwidth=80


" Tabs setting. In default we want 4 spaces tab, but allows also 8 spaced tabs
set noexpandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
function TabToogle()
	if &tabstop != 4
		set tabstop=4
		set shiftwidth=4
		set softtabstop=4
		echom 'Tab stop set to 4'
	else
		set tabstop=8
		set shiftwidth=8
		set softtabstop=8
		echom 'Tab stop set to 8'
	endif
	" Soft tab stop is here only for possibility of expandtab
endfunction
command TabToogle call TabToogle()

" Translate word under cursor
nnoremap <leader>d :! sdcv -n <cword><cr>

" netrw configuration
cabbrev E Explore
let g:netrw_banner=0
let g:netrw_liststyle=1
let g:netrw_list_hide='\(^\|\s\s\)\zs\.\S\+,'
function GitIgnore()
	" Possibly find and include all lower .gitignore files?
	let g:netrw_list_hide='\(^\|\s\s\)\zs\.\S\+,' . netrw_gitignore#Hide()
endfunction
command GitIgnore call GitIgnore()
" Some fast buffer switching and opening of new files
nnoremap <c-c><CR> :Explore<cr>
nnoremap <c-c>l :bnext<cr>
nnoremap <c-c>h :bprev<cr>

" Setup gitgutter
set updatetime=100
highlight GitGutterAdd ctermfg=2
highlight GitGutterChange ctermfg=3
highlight GitGutterDelete ctermfg=1

" Setup table-mode to markdown compliant
" Note: to start use "\ t m"
let g:table_mode_corner='|'

" Open tagbar with <F9>
nmap <F9> :TagbarOpen fc<cr>

" Spell checking
map <F10> :setlocal spell!<cr>
function LangToggle()
	if &spelllang !=? 'en_us'
		setlocal spelllang=en_us
		echo 'spelllang=en_us'
	else
		setlocal spelllang=cs
		echo 'spelllang=cs'
	endif
endfunction
setlocal spelllang=en_us
map <F11> :call LangToggle()<cr>

" NERDCommenter
let g:NERDCreateDefaultMappings = 1

" UltiSnips triggers
let g:UltiSnipsExpandTrigger='<c-h>'
let g:UltiSnipsJumpForwardTrigger='<c-j>'
let g:UltiSnipsJumpBackwardTrigger='<c-k>'

" ALE
let g:ale_set_baloons = 1
let g:ale_floating_preview = 1
let g:ale_use_neovim_diagnostics_api = 1
nmap <leader>f <Plug>(ale_fix)

" Telescope
nnoremap <c-c><c-c> :Telescope buffers<cr>
nnoremap <expr> <c-p> ":call TelescopeFiles()<cr>".expand('%:h')."/"
nnoremap <c-s-p> :Telescope lsp_document_symbols<cr>
nmap <leader>] :Telescope lsp_definitions<cr>
nmap <leader><leader>] :Telescope lsp_type_definitions<cr>
nmap <leader>[ :Telescope lsp_implementations<cr>
nmap <leader><leader>[ :Telescope lsp_references<cr>
function TelescopeFiles()
	if stridx(system('git rev-parse --is-inside-work-tree 2>/dev/null || true'), 'true') != -1
		lua require('telescope.builtin').git_files{use_file_path=true,git_command={"sh","-c","git ls-files -c --recurse-submodules && git ls-files -o --exclude-standard"}}
	else
		lua require('telescope.builtin').find_files{}
	endif
endfunction

" Copy line location
" TODO this should work but it doesn't for some reason
" nmap <leader><leader>c :let @+=expand("%:p") . ":" . line(".")<cr>
nmap <leader><leader>c :exec "!wl-copy '" . expand("%:p") . ":" . line(".") . "'"<cr><cr>