dotfiles/dot_spacevim

278 lines
7.2 KiB
Plaintext
Raw Normal View History

2019-06-08 01:46:49 +02:00
" vim: set ft=vim: syntax=vim
" Use exclude option if you don't want the full Layer,
" e.g., Layer 'better-defaults', { 'exclude': 'itchyny/vim-cursorword' }
function! Layers()
let g:spacevim_lsp_engine = 'coc'
2021-08-06 15:45:39 +02:00
let g:spacevim_speed_up_via_timer = 0
let g:spacevim_enable_startify = 0
" Polyglot configuration
let g:polyglot_disabled = ['systemd']
2019-06-08 01:46:49 +02:00
Layer 'airline'
Layer 'better-defaults', {'exclude': [
2019-06-08 01:46:49 +02:00
\ 'kshenoy/vim-signature',
\ 'google/vim-searchindex',
\ ] }
Layer 'docker'
2019-06-08 01:46:49 +02:00
Layer 'editing'
Layer 'fzf'
Layer 'git'
Layer 'lsp'
2019-06-08 01:46:49 +02:00
Layer 'markdown'
Layer 'programming', {'exclude': ['luochen1990/rainbow']}
Layer 'unite'
Layer 'syntax-checking'
2019-06-08 01:46:49 +02:00
endfunction
function! UserInit()
Plug 'andymass/vim-matchup'
Plug 'tpope/vim-repeat'
Plug 'pappasam/coc-jedi', { 'do': 'yarn install --frozen-lockfile && yarn build' }
Plug 'chr4/nginx.vim'
Plug 'Firef0x/PKGBUILD.vim'
Plug 'elzr/vim-json', { 'for': 'json' }
Plug 'TheEdgeOfRage/vim-pythonsense', { 'for': 'python' }
Plug 'hashivim/vim-terraform'
Plug 'morhetz/gruvbox'
2021-04-10 08:44:18 +02:00
Plug 'mbbill/undotree'
2021-10-21 15:10:02 +02:00
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install', 'for': ['markdown', 'vim-plug'] }
2021-11-12 12:30:46 +01:00
Plug 'mboughaba/i3config.vim'
2019-06-08 01:46:49 +02:00
endfunction
" Override the existing configurations and add extras here.
function! UserConfig()
set termguicolors
color gruvbox
set encoding=utf8
set shell=/bin/bash
set autochdir
set laststatus=2
"set timeoutlen=300
"set backspace=2
set showcmd
set wrap
set linebreak
set number
set relativenumber
set cursorline
set cursorcolumn
set tabstop=4
set shiftwidth=4
set softtabstop=4
set textwidth=0
set noexpandtab
set autoindent
set background=dark
set list
set listchars=tab:│\ ,trail:~,extends:>,precedes:<
set splitright
set splitbelow
set foldmethod=indent
" Persistent undo
set undofile
set undodir=~/.local/share/nvim/undodir
" Backspace and Enter as G and gg
nnoremap <CR> G
nnoremap <BS> gg
vnoremap <CR> G
vnoremap <BS> gg
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Colemak-Vim Mappings
"
" The idea is to use HNEI as arrows keeping the traditional Vim homerow style and changing as
" little else as possible. This means JKL are free to use and NEI need new keys.
" - k/K is the new n/N ["next/prev search"]
" - l/L is the new i/I ["insert"].
" - m/M is the new e/E ["jump" to EOW].
" - j/J is the new m/M ["marks"]
" - H/I skip to the beginning and end of lines. Much more intuitive than ^/$.
" - l replaces i as the "inner" modifier [e.g. "dlw" becomes "dlw"].
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" HNEI arrows.
noremap <silent> n j
noremap <silent> e k
noremap <silent> i l
" Merge lines
noremap <silent> N J
" Last search.
noremap k n
noremap K N
" mark
noremap j m
noremap J M
" l/L insert
noremap l i
noremap L I
" EOW.
noremap m e
noremap M E
" End of line
noremap I $
noremap H ^
noremap <C-N> <C-E>
noremap <C-E> <C-P>
" Disable default space action
noremap <Space> <NOP>
" Autoindent code
nmap <F7> jzgg=G`z
" Buffer actions
nnoremap <silent> <Tab> :bn<CR>
nnoremap <silent> <S-Tab> :bp<CR>
nnoremap <silent> <leader>bd :bp \| bd #<cr>
" Unhighlight search results with \
noremap <silent> \ :let @/ = ""<CR>
2021-04-10 08:47:20 +02:00
" Quickfix window mapping
nnoremap <Leader>cq :cclose<CR>
nnoremap <Leader>cn :cnext<CR>
nnoremap <Leader>cp :cprev<CR>
nnoremap <Leader>cf :cfirst<CR>
nnoremap <Leader>cl :clast<CR>
" Window keymapping
2020-03-29 19:03:38 +02:00
if !exists('g:vim_better_default_window_key_mapping') || g:vim_better_default_window_key_mapping
2019-06-08 01:46:49 +02:00
nnoremap <Leader>wn <C-W>j
nnoremap <Leader>we <C-W>k
nnoremap <Leader>wh <C-W>h
nnoremap <Leader>wi <C-W>l
nnoremap <Leader>wH <C-W>5<
nnoremap <Leader>wI <C-W>5>
nnoremap <Leader>wN :resize +5<CR>
nnoremap <Leader>wE :resize -5<CR>
endif
" FZF mappings
noremap <C-P> :GFiles<CR>
noremap <leader>ff :Files<CR>
noremap <C-G> :Lines<CR>
noremap <C-Q> :Buffers<CR>
noremap <C-T> :Tags<CR>
noremap <leader>? :Maps<CR>
" Nerdcommenter maps
nmap <Leader>/ <Plug>NERDCommenterToggle
vmap <Leader>/ <Plug>NERDCommenterToggle
" Fugitive maps
nnoremap <silent> <Leader>gd :Gvdiff<CR>
" Undotree maps
nnoremap <F3> :UndotreeToggle<cr>
""""""""""""""""""""""
" Plugin configuration
""""""""""""""""""""""
" Airline settings
let g:airline_powerline_fonts = 1
let g:airline_theme='gruvbox'
2021-02-10 16:28:38 +01:00
let g:airline#extensions#ale#enabled = 1
" Signify settings
let g:signify_sign_delete_first_line = '-'
2019-06-08 01:46:49 +02:00
" Per filetype indentation settings
augroup filetypeDefinitions
autocmd Filetype c,cpp setl noet ts=4 sts=4 sw=4
2021-08-06 15:45:39 +02:00
autocmd Filetype html setl noet ts=2 sts=2 sw=2
autocmd Filetype javascript,js setl et ts=4 sts=4 sw=4
autocmd Filetype json,jsonnet setl et ts=4 sts=4 sw=4
2022-05-27 12:33:17 +02:00
autocmd Filetype lua setl et ts=2 sts=2 sw=2
autocmd Filetype nginx setl noet ts=4 sts=4 sw=4
2019-09-03 10:31:13 +02:00
autocmd Filetype php setl et ts=4 sw=4 sts=4 tw=0
autocmd Filetype python setl et ts=4 sw=4 sts=4 tw=0
autocmd Filetype rst setl autoindent& cindent& smartindent& indentexpr& et ts=4 sts=4 sw=4
2020-03-24 13:01:57 +01:00
autocmd Filetype terraform setl et ts=2 sts=2 sw=2
autocmd Filetype tex setl et ts=4 sts=4 sw=4
autocmd Filetype typescript setl et ts=2 sts=2 sw=2
autocmd Filetype yaml,helm setl et ts=2 sts=2 sw=2
2019-06-08 01:46:49 +02:00
augroup END
augroup filetypedetect
autocmd BufNew,BufNewFile,BufRead *.network,*.netdev :setfiletype systemd
2021-09-11 18:24:02 +02:00
autocmd BufNew,BufNewFile,BufRead *.rasi setf css
2019-06-08 01:46:49 +02:00
augroup END
" Don't insert title into new files
autocmd! spacevimNewFile BufNewFile *.py,*.cpp,*.c,*.sh,*.java,*.pl
" Format files
2019-06-08 01:46:49 +02:00
command! FormatJSON %!python -m json.tool
command! FormatPython %!yapf
2019-06-08 01:46:49 +02:00
command! W :execute ':silent w !sudo tee % > /dev/null' | :edit!
2021-08-06 15:45:39 +02:00
" autocmd! spacevimStart
2019-06-08 01:46:49 +02:00
" Strip trailing whitespaces on save
fun! <SID>StripTrailingWhitespaces()
let l = line('.')
let c = col('.')
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd FileType * autocmd BufWritePre <buffer> :call <SID>StripTrailingWhitespaces()
" JSON disable quote conceal
let g:vim_json_syntax_conceal = 0
2019-06-08 01:46:49 +02:00
" Ale settings
let g:ale_linters = {
2020-12-06 11:33:11 +01:00
\ 'c': ['gcc'],
\ 'cpp': ['gcc'],
\ 'javascript': ['eslint'],
2021-10-10 13:00:50 +02:00
\ 'python': ['flake8', 'isort', 'mypy'],
2020-12-06 11:33:11 +01:00
\ }
2022-08-11 14:44:07 +02:00
let g:ale_fixers = {
2022-07-22 11:35:35 +02:00
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'go': ['gofmt', 'goimports', 'golines'],
2022-08-11 14:44:07 +02:00
\ 'terraform': ['terraform'],
2022-07-22 11:35:35 +02:00
\ }
2019-06-08 01:46:49 +02:00
let g:ale_lint_on_insert_leave = 1
2020-03-18 14:06:33 +01:00
let g:ale_fix_on_save = 1
2019-06-08 01:46:49 +02:00
" fzf config
let g:fzf_colors = {
\ 'fg': ['fg', 'GruvboxGray'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'GruvboxRed'],
\ 'fg+': ['fg', 'GruvboxGreen'],
\ 'bg+': ['bg', 'GruvboxBg1'],
\ 'hl+': ['fg', 'GruvboxRed'],
\ 'info': ['fg', 'GruvboxOrange'],
\ 'prompt': ['fg', 'GruvboxBlue'],
\ 'header': ['fg', 'GruvboxBlue'],
\ 'pointer': ['fg', 'Error'],
\ 'marker': ['fg', 'Error'],
\ 'spinner': ['fg', 'Statement'],
\ }
" NERDCommenter configuration
let g:NERDCustomDelimiters = {
\ 'requirements': {'left': '#'},
\ 'systemd': {'left': '#'},
\ 'vue': {'left': '//'},
\ }
let g:NERDDefaultAlign = 'left'
2021-09-26 20:46:31 +02:00
" Coc extensions
2022-04-13 23:47:53 +02:00
let g:coc_global_extensions = ['coc-json', 'coc-jedi', 'coc-tsserver', 'coc-vetur', 'coc-go']
2019-06-08 01:46:49 +02:00
endfunction