dotfiles.nix/assets/init.vim

76 lines
2.6 KiB
VimL

syntax on
filetype plugin indent on
set cursorline "highlight current line
set showmatch "highlight matching [{()}]
set tabstop=2 "number of visual spaces per TAB when reading
set softtabstop=2 "number of spaces per TAB when editing
set expandtab "tabs are spaces
set shiftwidth=2 "indents
set ww=<,>,[,] "wrap
set splitbelow "split underneath
set splitright "split to the right
command Mks NERDTreeClose | mksession!
command Term split | term
command Vterm vsplit | term
"command Hsfmt mark H | %!./styler.sh | if v:shell_error | undo | else | `H | delm H | endif
"save readonly
cmap w!! w !sudo tee >/dev/null %
"terminal exit
tnoremap <Esc> <C-\><C-n><CR>
"nohl
nnoremap <silent> ,<space> :nohlsearch<CR>
colorscheme Tomorrow-Night-Eighties
let g:lightline = {'colorscheme': 'jellybeans'}
"cursor saving
autocmd BufReadPost * if @% !~# '\.git[\/\\]COMMIT_EDITMSG$' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
"nerdtree
"show hidden files
let NERDTreeShowHidden=1
"open on vim open
"autocmd vimenter * NERDTree
"switch to editing window
"autocmd vimenter * wincmd p
"close if only nerdtree is left
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
"show/hide nerdtree
nnoremap <silent> <c-b> :NERDTreeToggle<CR>
"LSP support
set hidden
let g:LanguageClient_rootMarkers = ['*.cabal', 'stack.yaml']
let g:LanguageClient_serverCommands = {
\ 'haskell': ['ghcide', '--lsp'],
\ }
let g:LanguageClient_preferredMarkupKind = ['plaintext']
let g:LanguageClient_completionPreferTextEdit = 1
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> f :call LanguageClient#textDocument_rangeFormatting()<CR>
nnoremap <silent> F :call LanguageClient#textDocument_formatting()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> gr :call LanguageClient#textDocument_references()<CR>
set cmdheight=2
set updatetime=300
set signcolumn=yes
"NCM2
autocmd bufenter * call ncm2#enable_for_buffer()
au User Ncm2PopupOpen set completeopt=noinsert,menuone,noselect
au User Ncm2PopupClose set completeopt=menuone
set shortmess+=c
" CTRL-C doesn't trigger the InsertLeave autocmd . map to <ESC> instead.
inoremap <c-c> <ESC>
" When the <Enter> key is pressed while the popup menu is visible, it only
" hides the menu. Use this mapping to close the menu and also start a new
" line.
inoremap <expr> <CR> (pumvisible() ? "\<c-y>\<cr>" : "\<CR>")
" Use <TAB> to select the popup menu:
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"