Updating neovim config
This commit is contained in:
parent
1e649ca3ca
commit
36bf8e01c5
3 changed files with 202 additions and 188 deletions
12
nvim/nvim.symlink/UltiSnips/typescript.snippets
Normal file
12
nvim/nvim.symlink/UltiSnips/typescript.snippets
Normal file
|
@ -0,0 +1,12 @@
|
|||
snippet mochatest
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
|
||||
import $1 from '$2';
|
||||
|
||||
describe('$3', () => {
|
||||
it('should $4', () => {
|
||||
$0
|
||||
});
|
||||
});
|
||||
endsnippet
|
2
nvim/nvim.symlink/coc-settings.json
Normal file
2
nvim/nvim.symlink/coc-settings.json
Normal file
|
@ -0,0 +1,2 @@
|
|||
{
|
||||
}
|
|
@ -1,98 +1,63 @@
|
|||
" Basic editing config
|
||||
|
||||
" colorscheme maxbucknell
|
||||
set termguicolors
|
||||
set updatetime=100
|
||||
|
||||
" Let's get the plugins out of the way first, shall we?
|
||||
call plug#begin()
|
||||
" Pane Navigation (Tmux integration)
|
||||
" Colours
|
||||
Plug 'morhetz/gruvbox'
|
||||
|
||||
" Pane Navigation (Tmux integration)
|
||||
Plug 'christoomey/vim-tmux-navigator'
|
||||
" Fuzzy finding
|
||||
Plug '/usr/local/opt/fzf'
|
||||
Plug 'junegunn/fzf.vim'
|
||||
|
||||
" Colours
|
||||
Plug 'morhetz/gruvbox'
|
||||
" Completion
|
||||
Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}}
|
||||
|
||||
" Fuzzy finding
|
||||
Plug '/usr/local/opt/fzf'
|
||||
" Snippets
|
||||
Plug 'SirVer/ultisnips'
|
||||
Plug 'honza/vim-snippets'
|
||||
|
||||
" Snippets
|
||||
Plug 'SirVer/ultisnips'
|
||||
Plug 'honza/vim-snippets'
|
||||
" Surround
|
||||
Plug 'tpope/vim-surround'
|
||||
|
||||
" Git integration
|
||||
Plug 'tpope/vim-fugitive'
|
||||
Plug 'airblade/vim-gitgutter'
|
||||
" Git integration
|
||||
Plug 'tpope/vim-fugitive'
|
||||
Plug 'airblade/vim-gitgutter'
|
||||
|
||||
" Linting
|
||||
Plug 'neomake/neomake'
|
||||
Plug 'w0rp/ale'
|
||||
" Comments
|
||||
Plug 'tpope/vim-commentary'
|
||||
|
||||
" Comments
|
||||
Plug 'tpope/vim-commentary'
|
||||
" Statusline
|
||||
Plug 'vim-airline/vim-airline'
|
||||
|
||||
" File browsing
|
||||
Plug 'francoiscabrol/ranger.vim'
|
||||
Plug 'rbgrouleff/bclose.vim'
|
||||
" TypeScript
|
||||
Plug 'HerringtonDarkholme/yats.vim'
|
||||
|
||||
" Statusline
|
||||
Plug 'vim-airline/vim-airline'
|
||||
" Go
|
||||
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
|
||||
|
||||
" For async completion
|
||||
Plug 'Shougo/deoplete.nvim'
|
||||
" Rust
|
||||
Plug 'rust-lang/rust.vim'
|
||||
|
||||
" TypeScript
|
||||
Plug 'HerringtonDarkholme/yats.vim'
|
||||
Plug 'mhartington/nvim-typescript', {'do': './install.sh'}
|
||||
" CSV
|
||||
Plug 'chrisbra/csv.vim'
|
||||
|
||||
" Go
|
||||
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
|
||||
Plug 'deoplete-plugins/deoplete-go', { 'do': 'make'}
|
||||
|
||||
" Rust
|
||||
Plug 'rust-lang/rust.vim'
|
||||
Plug 'sebastianmarkow/deoplete-rust'
|
||||
|
||||
" CSV
|
||||
Plug 'chrisbra/csv.vim'
|
||||
" CSS Colour previews
|
||||
"
|
||||
" Working on changing this, making it use virtual text to render a swatch.
|
||||
Plug 'chrisbra/Colorizer'
|
||||
call plug#end()
|
||||
|
||||
" Theme configuration
|
||||
let g:gruvbox_italic = 1
|
||||
colorscheme gruvbox
|
||||
" I have a true colour terminal, and I will have true colours in my Vim
|
||||
set termguicolors
|
||||
|
||||
" Use ranger instead of netrw
|
||||
let g:ranger_replace_netrw = 1
|
||||
|
||||
" Setting up autocomplete
|
||||
let g:deoplete#enable_at_startup = 1
|
||||
|
||||
" Quick exit insert mode
|
||||
" Disable creation of swap files.
|
||||
"
|
||||
" Escape is at the far corner of my keyboard, and having it so far away
|
||||
" was discouraging me from exiting insert mode. Qwerty users can remap
|
||||
" jk to <esc>, which is a far better solution. The keys are next to each
|
||||
" other, and it makes exiting insert mode a pleasant rolling motion.
|
||||
" Moreover, when in normal mode, jk is a no-op.
|
||||
" Swap files serve a purpose, but not to me. I write often, and so
|
||||
" these just get in the way.
|
||||
"
|
||||
" As a dvorak user, jk was too cumbersome, but there were no other
|
||||
" suitable candidates. hh is inferior in that it is not a no-op in
|
||||
" normal mode, but it is just as easy to type. The only caveat is when
|
||||
" an edit ends with h, which is why hhh will expand to place an h in
|
||||
" the buffer before exiting.
|
||||
"
|
||||
" To encourage me to adopt the new style, I disable escape. That one is
|
||||
" sure to mess up someone not familiar with my setup.
|
||||
inoremap hh <esc>
|
||||
inoremap hhh h<esc>
|
||||
" Terminal mode setting
|
||||
tnoremap hh <C-\><C-n>
|
||||
tnoremap hhh h<C-\><C-n>
|
||||
|
||||
" Lead with the biggest button on the motherfucking keyboard
|
||||
let mapleader = "\<space>"
|
||||
|
||||
" FUzzy finding
|
||||
nnoremap <leader>o :FZF<cr>
|
||||
" I'm toying with the idea of re-enabling these and ignoring them in Git.
|
||||
set nobackup
|
||||
set nowritebackup
|
||||
set noswapfile
|
||||
|
||||
" Don't wrap lines
|
||||
"
|
||||
|
@ -137,17 +102,6 @@ set showcmd
|
|||
" have the memory to spare to keep them around.
|
||||
set hidden
|
||||
|
||||
" Enable highlighting for syntax
|
||||
syntax on
|
||||
|
||||
" Enable file type detection.
|
||||
"
|
||||
" Use the default filetype settings, so that mail gets 'tw' set to 72,
|
||||
" 'cindent' is on in C files, etc.
|
||||
" Also load indent files, to automatically do language-dependent
|
||||
" indenting.
|
||||
filetype plugin indent on
|
||||
|
||||
" Insert only one space when joining lines that contain
|
||||
" sentence-terminating punctuation like `.`.
|
||||
set nojoinspaces
|
||||
|
@ -165,20 +119,13 @@ set listchars=tab:‣\ ,trail:·
|
|||
" of my text in it, no funny business.
|
||||
set foldmethod=manual
|
||||
set nofoldenable
|
||||
let g:vim_markdown_folding_disabled=1
|
||||
let g:vimtex_fold_enabled=0
|
||||
|
||||
""""""""""""""""""
|
||||
" Ultisnips, y'all
|
||||
""""""""""""""""""
|
||||
|
||||
let g:UltiSnipsExpandTrigger="<tab>"
|
||||
let g:UltiSnipsJumpForwardTrigger="<tab>"
|
||||
let g:UltiSnipsJumpBackwardTrigger="<S-tab>"
|
||||
" Scrolloff, because I'm allergic to the edges of my screen
|
||||
set scrolloff=5
|
||||
|
||||
" Tab config options
|
||||
"
|
||||
" In general, I prefer spaces to tabs, and 2-space indentation. These
|
||||
" In general, I prefer spaces to tabs, and 4-space indentation. These
|
||||
" settings just make that consistent, so I rarely have to think about
|
||||
" it.
|
||||
set expandtab
|
||||
|
@ -187,7 +134,99 @@ set shiftwidth=4
|
|||
set softtabstop=4
|
||||
set autoindent
|
||||
|
||||
" Enable highlighting for syntax
|
||||
syntax on
|
||||
|
||||
" Enable file type detection.
|
||||
filetype plugin indent on
|
||||
|
||||
" Theme configuration
|
||||
let g:gruvbox_italic = 1
|
||||
colorscheme gruvbox
|
||||
|
||||
" Lead with the biggest button on the motherfucking keyboard
|
||||
let mapleader = "\<space>"
|
||||
let localmapleader = "\\"
|
||||
|
||||
" Quick exit insert mode
|
||||
"
|
||||
" Escape is at the far corner of my keyboard, and having it so far away
|
||||
" was discouraging me from exiting insert mode. Qwerty users can remap
|
||||
" jk to <esc>, which is a far better solution. The keys are next to each
|
||||
" other, and it makes exiting insert mode a pleasant rolling motion.
|
||||
" Moreover, when in normal mode, jk is a no-op.
|
||||
"
|
||||
" As a dvorak user, jk was too cumbersome, but there were no other
|
||||
" suitable candidates. hh is inferior in that it is not a no-op in
|
||||
" normal mode, but it is just as easy to type. The only caveat is when
|
||||
" an edit ends with h, which is why hhh will expand to place an h in
|
||||
" the buffer before exiting.
|
||||
"
|
||||
" To encourage me to adopt the new style, I disable escape. That one is
|
||||
" sure to mess up someone not familiar with my setup.
|
||||
inoremap hh <esc>
|
||||
inoremap hhh h<esc>
|
||||
|
||||
" Terminal mode setting
|
||||
tnoremap hh <C-\><C-n>
|
||||
tnoremap hhh h<C-\><C-n>
|
||||
|
||||
" Visual mode setting
|
||||
vnoremap hh <esc>
|
||||
vnoremap hhh h<esc>
|
||||
|
||||
" Fuzzy finding
|
||||
nnoremap <leader>o :Files<cr>
|
||||
nnoremap <leader>b :Buffers<cr>
|
||||
|
||||
" Go to most recently edited file
|
||||
nnoremap <leader><leader> <c-^>
|
||||
|
||||
" Ultisnips, y'all
|
||||
let g:UltiSnipsExpandTrigger="<tab>"
|
||||
let g:UltiSnipsJumpForwardTrigger="<tab>"
|
||||
let g:UltiSnipsJumpBackwardTrigger="<S-tab>"
|
||||
|
||||
" Remap semi-colon to colon.
|
||||
"
|
||||
" Colon is the starting point of a lot of actions in Vim. And I
|
||||
" shouldn't have to hold a modifier key to access so much
|
||||
" essential functionality.
|
||||
noremap ; :
|
||||
noremap ;; ;
|
||||
|
||||
" Git blame
|
||||
"
|
||||
" I used to do this by just filling in my buffer, but this is nicer.
|
||||
nnoremap <leader>a :Gblame<cr>
|
||||
|
||||
" What the hell is ex mode
|
||||
"
|
||||
" Whatever it is, I don't like it.
|
||||
nnoremap Q <nop>
|
||||
|
||||
" Traversing lines
|
||||
nnoremap - ddp
|
||||
nnoremap _ :-1d<cr>pk
|
||||
|
||||
" Updating Vimrc
|
||||
"
|
||||
" A little mapping to edit my vimrc. I'd like to do this with a function, and
|
||||
" account for a few things:
|
||||
"
|
||||
" + Is a buffer already open and visible?
|
||||
" + Open in a floating window over everything to not disturb my workflow
|
||||
nnoremap <leader>ev :vsp $MYVIMRC<cr>
|
||||
|
||||
" Second part, every time I write to $MYVIMRC, source it for me.
|
||||
augroup updateVimrc
|
||||
autocmd BufWritePost $MYVIMRC :source $MYVIMRC
|
||||
augroup END
|
||||
|
||||
" Zoom the current split
|
||||
"
|
||||
" Tmux has a feature <prefix>-z, that will zoom the current pane. I decided
|
||||
" that this was a useful enough feature to have in Vim as well. Voila.
|
||||
function! ZoomOrUnzoom()
|
||||
if exists('g:is_zoomed')
|
||||
unlet g:is_zoomed
|
||||
|
@ -199,6 +238,11 @@ function! ZoomOrUnzoom()
|
|||
endif
|
||||
endfunc
|
||||
|
||||
" Map it to <space>z
|
||||
nnoremap <leader>z :call ZoomOrUnzoom()<cr>
|
||||
|
||||
" I had this running as an autocommand on resizes, but it was buggy so it's
|
||||
" disabled at the moment.
|
||||
function! HandleResize()
|
||||
if exists('g:is_zoomed')
|
||||
execute "wincmd _"
|
||||
|
@ -208,16 +252,17 @@ function! HandleResize()
|
|||
endif
|
||||
endfunc
|
||||
|
||||
nnoremap <C-z> :call ZoomOrUnzoom()<cr>
|
||||
|
||||
" A load of default file runners. These need to be refactored, so that they
|
||||
" are in filetype plugins, and would probably be better served by being bound
|
||||
" to the localleader.
|
||||
function! RunTypeScript()
|
||||
silent !clear
|
||||
execute "!tsc % --outFile /dev/stdout | node"
|
||||
execute "!$(findroot package.json)/node_modules/.bin/mocha -r ts-node/register -R dot %"
|
||||
endfunction
|
||||
|
||||
function! RunJavaScript()
|
||||
silent !clear
|
||||
execute "!node %"
|
||||
execute "!$(findroot package.json)/node_modules/.bin/mocha -R dot %"
|
||||
endfunction
|
||||
|
||||
function! RunPython()
|
||||
|
@ -230,17 +275,27 @@ function! RunRust()
|
|||
execute "!cargo run"
|
||||
endfunction
|
||||
|
||||
augroup vimrcEx
|
||||
" Clear all autocmds in the group
|
||||
function! OpenInMarked()
|
||||
silent !clear
|
||||
execute '!open "x-marked://open?file=%:p"'
|
||||
endfunction
|
||||
|
||||
augroup runFiles
|
||||
autocmd!
|
||||
|
||||
" Language whitespace settings
|
||||
autocmd FileType make setl noet sw=8 sts=8 ts=8
|
||||
autocmd FileType typescript nnoremap <localleader>r :call RunTypeScript()<cr>
|
||||
autocmd FileType javascript nnoremap <localleader>r :call RunJavaScript()<cr>
|
||||
autocmd FileType python nnoremap <localleader>r :call RunPython()<cr>
|
||||
autocmd FileType rust nnoremap <localleader>r :call RunRust()<cr>
|
||||
autocmd FileType markdown nnoremap <localleader>r :call OpenInMarked()<cr>
|
||||
augroup END
|
||||
|
||||
autocmd FileType typescript nnoremap <leader>r :call RunTypeScript()<cr>
|
||||
autocmd FileType javascript nnoremap <leader>r :call RunJavaScript()<cr>
|
||||
autocmd FileType python nnoremap <leader>r :call RunPython()<cr>
|
||||
autocmd FileType rust nnoremap <leader>r :call RunRust()<cr>
|
||||
" Text formatting rules for various files.
|
||||
augroup textFormatting
|
||||
autocmd!
|
||||
|
||||
" Make files really need tabs
|
||||
autocmd FileType make setl noet sw=8 sts=8 ts=8
|
||||
|
||||
" Hard wrap prose
|
||||
"
|
||||
|
@ -250,23 +305,24 @@ augroup vimrcEx
|
|||
autocmd FileType
|
||||
\ markdown,text
|
||||
\ setl tw=80 fo=t1
|
||||
augroup END
|
||||
|
||||
" I'm not interested in line numbers on terminal buffers. I hardly ever use
|
||||
" terminal buffers anyway, but they are useful in a few cases.
|
||||
"
|
||||
" I never want line numbering.
|
||||
augroup lineNumbering
|
||||
autocmd!
|
||||
|
||||
autocmd TermOpen * setl nonu nornu
|
||||
augroup END
|
||||
|
||||
augroup terminalInsert
|
||||
" Automatically enter terminal mode when summoning a terminal
|
||||
autocmd TermOpen term://* startinsert
|
||||
|
||||
" Lay out splits when Vim gets resized
|
||||
autocmd VimResized * :call HandleResize()<cr>
|
||||
|
||||
augroup END
|
||||
|
||||
" Make directories in a filename if they don't exist.
|
||||
|
||||
function! AskQuit (msg, options, quit_option)
|
||||
if confirm(a:msg, a:options) == a:quit_option
|
||||
exit
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! EnsureDirExists ()
|
||||
let required_dir = expand("%:h")
|
||||
if !isdirectory(required_dir)
|
||||
|
@ -284,45 +340,20 @@ augroup AutoMkdir
|
|||
autocmd BufNewFile * :call EnsureDirExists()
|
||||
augroup END
|
||||
|
||||
" Ale
|
||||
"
|
||||
" An asynchronous linting engine.
|
||||
let g:ale_lint_on_text_changed = 1
|
||||
|
||||
" Hallelujah!
|
||||
let g:ale_set_signs = 1
|
||||
let g:ale_sign_column_always = 1
|
||||
let g:ale_sign_error = '--'
|
||||
let g:ale_sign_warning = '--'
|
||||
|
||||
" Gitgutter
|
||||
let g:gitgutter_realtime = 1
|
||||
let g:gitgutter_eager = 1
|
||||
|
||||
" JSX in mah JavaScript
|
||||
let g:jsx_ext_required = 0
|
||||
|
||||
" Status line stuff
|
||||
let g:airline#extensions#ale#enabled = 1
|
||||
let g:airline#extensions#tabline#enabled = 1
|
||||
" Input supports patched fonts already \o/
|
||||
let g:airline_powerline_fonts = 1
|
||||
|
||||
|
||||
" Go to most recently edited file
|
||||
nnoremap <leader><leader> <c-^>
|
||||
|
||||
" Disable syntax hiding in JSON
|
||||
"
|
||||
" Vim JSON provides a fancy way of viewing, where it hides quotes and
|
||||
" just shows you data. I don't want that.
|
||||
let g:vim_json_syntax_conceal = 0
|
||||
|
||||
" Show syntax highlighting groups for word under cursor
|
||||
"
|
||||
" This is useful for finding rogue elements I forgot in my colour
|
||||
" scheme.
|
||||
nnoremap <leader>\ :call <SID>SynStack()<CR>
|
||||
function! <SID>SynStack()
|
||||
if !exists("*synstack")
|
||||
return
|
||||
|
@ -330,35 +361,4 @@ function! <SID>SynStack()
|
|||
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val,"name")')
|
||||
endfunc
|
||||
|
||||
" Remap semi-colon to colon.
|
||||
"
|
||||
" Colon is the starting point of a lot of actions in Vim. And I
|
||||
" shouldn't have to hold a modifier key to access so much
|
||||
" essential functionality.
|
||||
noremap ; :
|
||||
noremap ;; ;
|
||||
|
||||
" Commenting aliases, because I hate change.
|
||||
nnoremap <leader>/ :.Commentary<cr>
|
||||
|
||||
" Git blame
|
||||
"
|
||||
" I used to do this by just filling in my buffer, but this is nicer.
|
||||
nnoremap <leader>a :Gblame<cr>
|
||||
|
||||
" Disable creation of swap files.
|
||||
"
|
||||
" Swap files serve a purpose, but not to me. I write often, and so
|
||||
" these just get in the way.
|
||||
set nobackup
|
||||
set nowritebackup
|
||||
set noswapfile
|
||||
|
||||
" What the hell is ex mode
|
||||
"
|
||||
" Whatever it is, I don't like it.
|
||||
nnoremap Q <nop>
|
||||
|
||||
" Summon a terminal
|
||||
nnoremap <leader>k :bot sp term://zsh<cr>
|
||||
|
||||
nnoremap <leader>\ :call <SID>SynStack()<CR>
|
||||
|
|
Loading…
Add table
Reference in a new issue