2021-07-19 19:51:35 +00:00
|
|
|
" Prefer $HOME/.vim to $HOME/.config/nvim (for now):
|
2021-06-22 04:24:37 +00:00
|
|
|
set runtimepath^=~/.vim runtimepath+=~/.vim/after
|
|
|
|
let &packpath = &runtimepath
|
|
|
|
|
|
|
|
set background=dark
|
|
|
|
syntax on
|
|
|
|
filetype plugin indent on
|
|
|
|
|
|
|
|
let mapleader=','
|
|
|
|
|
|
|
|
" netrw
|
|
|
|
let g:netrw_banner = 0
|
|
|
|
let g:netrw_liststyle = 1
|
|
|
|
let g:netrw_list_hide = '^\.'
|
|
|
|
let g:netrw_winsize=25
|
|
|
|
map <leader>n <esc>:Lexplore<cr>
|
|
|
|
|
|
|
|
" fix helptags for opt/ plugins
|
|
|
|
" https://vi.stackexchange.com/questions/17210/generating-help-tags-for-packages-that-are-loaded-by-vim-8s-package-management
|
|
|
|
command! -nargs=0 -bar Helptags
|
|
|
|
\ for p in glob('~/.vim/pack/git-plugins/opt/*', 1, 1)
|
|
|
|
\| exe 'packadd ' . fnamemodify(p, ':t')
|
|
|
|
\| endfor
|
|
|
|
\| helptags ALL
|
|
|
|
|
|
|
|
set shiftwidth=2
|
|
|
|
set shiftround
|
|
|
|
set tabstop=2
|
|
|
|
set expandtab
|
|
|
|
set smarttab
|
|
|
|
set splitbelow
|
|
|
|
set splitright
|
|
|
|
set encoding=utf-8
|
|
|
|
set hidden
|
|
|
|
set nowrap
|
|
|
|
set smartindent
|
|
|
|
set copyindent
|
|
|
|
set autoindent
|
|
|
|
set hlsearch
|
|
|
|
set showmatch
|
|
|
|
set wildmenu
|
|
|
|
set wildmode=list:full,full
|
|
|
|
set number
|
|
|
|
set relativenumber
|
|
|
|
set ruler
|
|
|
|
set backspace=indent,eol,start
|
|
|
|
set ignorecase
|
|
|
|
set smartcase
|
|
|
|
set incsearch
|
|
|
|
set history=1000
|
|
|
|
set undolevels=1000
|
|
|
|
set title
|
|
|
|
set novisualbell
|
|
|
|
set noerrorbells
|
|
|
|
set nobackup
|
|
|
|
set noswapfile
|
|
|
|
set mouse=a
|
|
|
|
set mousemodel=popup_setpos
|
|
|
|
" https://github.com/tpope/vim-sensible/issues/78:
|
|
|
|
set lazyredraw
|
|
|
|
set timeoutlen=1000
|
|
|
|
set scrolloff=15
|
|
|
|
set dictionary=/usr/share/dict/words
|
|
|
|
" See :help thesaurus
|
|
|
|
set thesaurus=$HOME/Documents/thesaurus/thesaurus_pkg/thesaurus.txt
|
|
|
|
set shortmess+=I
|
|
|
|
set updatetime=250
|
|
|
|
set pastetoggle=<f2>
|
|
|
|
set pumheight=200
|
|
|
|
" Required for nvim-compe:
|
|
|
|
set completeopt=menuone,noselect
|
|
|
|
set complete-=i
|
|
|
|
set nrformats-=octal
|
|
|
|
set ttimeout
|
|
|
|
set ttimeoutlen=100
|
|
|
|
set formatoptions+=j
|
|
|
|
set autoread
|
|
|
|
" https://github.com/tpope/vim-sensible/issues/142:
|
|
|
|
set synmaxcol=500
|
|
|
|
|
|
|
|
" Enable 24-bit colours.
|
|
|
|
" https://github.com/alacritty/alacritty/issues/109#issuecomment-440353106
|
|
|
|
if exists('+termguicolors')
|
|
|
|
let &t_8f="\<Esc>[38;2;%lu;%lu;%lum"
|
|
|
|
let &t_8b="\<Esc>[48;2;%lu;%lu;%lum"
|
|
|
|
set termguicolors
|
|
|
|
endif
|
|
|
|
|
|
|
|
" Colour scheme:
|
|
|
|
packadd! nord-vim " https://github.com/arcticicestudio/nord-vim.git
|
|
|
|
colorscheme nord
|
|
|
|
|
|
|
|
augroup vimrc
|
|
|
|
autocmd!
|
|
|
|
" Automatically load/save views on files.
|
|
|
|
" https://vi.stackexchange.com/posts/13874/revisions
|
|
|
|
autocmd BufWinLeave,BufLeave,BufWritePost,BufHidden,QuitPre ?* nested silent! mkview!
|
|
|
|
autocmd BufWinEnter ?* silent! loadview
|
|
|
|
" set cursor line highlight in insert mode.
|
|
|
|
autocmd InsertEnter * set cul
|
|
|
|
autocmd InsertLeavePre * set nocul
|
|
|
|
" use tabs in .gitconfig
|
|
|
|
autocmd BufEnter .gitconfig setlocal shiftwidth=2 tabstop=2 noexpandtab
|
|
|
|
" Quickfix window is always full-width.
|
|
|
|
" https://github.com/fatih/vim-go/issues/1757#issuecomment-565130503
|
|
|
|
autocmd FileType qf if (getwininfo(win_getid())[0].loclist != 1) | wincmd J | endif
|
|
|
|
" Remove trailing whitespace pre-save:
|
|
|
|
autocmd FileType go,ruby,markdown,rust,python,markdown,lua autocmd BufWritePre <buffer> %s/\s\+$//e
|
|
|
|
augroup end
|
|
|
|
|
|
|
|
" Don't remember the current directory for a given file:
|
|
|
|
set viewoptions-=curdir
|
|
|
|
set viewoptions-=options
|
|
|
|
set sessionoptions-=options
|
|
|
|
|
|
|
|
" Key mappings:
|
|
|
|
nnoremap j gj
|
|
|
|
nnoremap k gk
|
|
|
|
map <up> <nop>
|
|
|
|
map <down> <nop>
|
|
|
|
map <left> <nop>
|
|
|
|
map <right> <nop>
|
|
|
|
imap <up> <nop>
|
|
|
|
imap <down> <nop>
|
|
|
|
imap <left> <nop>
|
|
|
|
imap <right> <nop>
|
|
|
|
nmap ]q :cn<cr>
|
|
|
|
nmap [q :cp<cr>
|
|
|
|
|
|
|
|
nnoremap <silent> <leader>w :w<cr>
|
|
|
|
nnoremap <silent> <leader>/ :nohlsearch<cr>
|
|
|
|
nnoremap <silent> <leader><space> :nohlsearch<cr>
|
|
|
|
" Select just-pasted text:
|
|
|
|
nnoremap <silent> <leader>0 `[v`]
|
|
|
|
" Select just-pasted text and re-indent:
|
|
|
|
nnoremap <silent> <leader>) `[v`]=
|
|
|
|
nnoremap <silent> <leader>1 :set relativenumber!<cr>
|
|
|
|
nnoremap <silent> <leader>! :windo set norelativenumber<cr>
|
|
|
|
nnoremap <leader>m :marks<cr>
|
|
|
|
nnoremap <leader>v :vsplit<cr>
|
|
|
|
nnoremap <leader>s :split<cr>
|
|
|
|
nnoremap <leader>rp "_dd<bar>P
|
2021-07-20 07:52:24 +00:00
|
|
|
nnoremap <leader>dq ggVG"_d:wq<cr>
|
2021-06-22 04:24:37 +00:00
|
|
|
|
|
|
|
lua <<EOF
|
2021-07-15 06:21:56 +00:00
|
|
|
function _G.dump(...)
|
|
|
|
local objects = vim.tbl_map(vim.inspect, {...})
|
|
|
|
print(unpack(objects))
|
|
|
|
return ...
|
|
|
|
end
|
|
|
|
|
2021-06-22 04:24:37 +00:00
|
|
|
function _G.insert_uuid()
|
|
|
|
local uuid = vim.call("system", "uuidprint")
|
2021-07-20 07:52:24 +00:00
|
|
|
local errcode = vim.v.shell_error
|
|
|
|
if errcode ~= 0 then
|
|
|
|
vim.api.nvim_err_writeln("uuidprint returned error code: " .. errcode)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2021-06-22 04:24:37 +00:00
|
|
|
vim.call("setreg", "u", uuid)
|
|
|
|
vim.api.nvim_command([[normal! "up]])
|
|
|
|
end
|
|
|
|
|
|
|
|
vim.api.nvim_set_keymap("n", "<leader>uu", [[:lua _G.insert_uuid()<cr>]], {noremap = true, silent = true})
|
|
|
|
vim.api.nvim_set_keymap("i", "<c-d><c-u>", [[<esc>:lua _G.insert_uuid()<cr>a]], {noremap = true, silent = true})
|
2021-07-14 16:00:28 +00:00
|
|
|
|
2021-07-20 07:52:24 +00:00
|
|
|
function _G.insert_jira_url()
|
|
|
|
local url = vim.call("system", "jira")
|
|
|
|
local errcode = vim.v.shell_error
|
|
|
|
if errcode ~= 0 then
|
|
|
|
vim.api.nvim_err_writeln("jira returned error code: " .. errcode)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
vim.call("setreg", "u", url)
|
|
|
|
vim.api.nvim_command([[normal! "up]])
|
|
|
|
end
|
|
|
|
|
|
|
|
vim.api.nvim_set_keymap("n", "<leader>ji", [[:lua _G.insert_jira_url()<cr>]], {noremap = true, silent = true})
|
|
|
|
vim.api.nvim_set_keymap("i", "<c-d><c-j>", [[<esc>:lua _G.insert_jira_url()<cr>a]], {noremap = true, silent = true})
|
|
|
|
|
2021-07-15 06:21:56 +00:00
|
|
|
_G._test_cmd_to_wins = {}
|
2021-07-14 16:00:28 +00:00
|
|
|
|
2021-07-15 06:21:56 +00:00
|
|
|
_G._build_test_cmd = function()
|
|
|
|
local bufnr = vim.call("bufnr", "%")
|
|
|
|
local filetype = vim.call("getbufvar", bufnr, "&filetype")
|
2021-07-14 16:00:28 +00:00
|
|
|
if filetype == "" then
|
2021-07-27 07:05:29 +00:00
|
|
|
vim.api.nvim_err_writeln("cannot build test command for filetype:" .. filetype)
|
2021-07-15 06:21:56 +00:00
|
|
|
return nil
|
2021-07-14 16:00:28 +00:00
|
|
|
end
|
|
|
|
|
2021-07-15 06:21:56 +00:00
|
|
|
local path = vim.call("expand", "%:p")
|
|
|
|
|
|
|
|
-- TODO: allow line number to be passed
|
|
|
|
-- TODO: check file exists before running command
|
2021-07-14 16:00:28 +00:00
|
|
|
if filetype == "ruby" then
|
2021-07-15 06:21:56 +00:00
|
|
|
if not path:find("_spec.rb") then
|
|
|
|
path = path:gsub("/app/", "/spec/"):gsub([[.rb$]], "_spec.rb")
|
|
|
|
end
|
|
|
|
|
2021-07-27 09:35:26 +00:00
|
|
|
return "bundle exec rspec --format=progress --no-profile " .. path
|
2021-07-15 06:21:56 +00:00
|
|
|
elseif filetype == "go" then
|
|
|
|
return "go test " .. path:gsub("^(.*)/(.*go)$", "%1/...")
|
|
|
|
else
|
2021-07-27 07:05:29 +00:00
|
|
|
vim.api.nvim_err_writeln("filetype not supported: " .. filetype)
|
2021-07-15 06:21:56 +00:00
|
|
|
return nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
_G.run_tests = function()
|
|
|
|
local cmd = _G._build_test_cmd()
|
|
|
|
if cmd == nil then
|
2021-07-14 16:00:28 +00:00
|
|
|
return
|
|
|
|
end
|
2021-07-15 06:21:56 +00:00
|
|
|
|
|
|
|
vim.api.nvim_command([[silent up]])
|
|
|
|
|
|
|
|
local winid = _G._test_cmd_to_wins[cmd]
|
2021-07-21 09:30:46 +00:00
|
|
|
local current_winid = vim.call("win_getid")
|
|
|
|
if winid == nil or not vim.api.nvim_win_is_valid(winid) or winid == current_winid or not vim.call("win_gotoid", winid) == -1 then
|
2021-07-15 06:21:56 +00:00
|
|
|
vim.api.nvim_command([[10split]])
|
|
|
|
winid = vim.call("win_getid")
|
|
|
|
_G._test_cmd_to_wins[cmd] = winid
|
|
|
|
end
|
|
|
|
|
|
|
|
local buf = vim.api.nvim_create_buf(false, true)
|
|
|
|
vim.api.nvim_buf_set_option(buf, "bufhidden", "delete")
|
|
|
|
vim.api.nvim_win_set_buf(winid, buf)
|
|
|
|
|
|
|
|
vim.call("termopen", cmd)
|
|
|
|
vim.api.nvim_command([[normal! G]])
|
|
|
|
vim.api.nvim_command([[wincmd p]])
|
|
|
|
end
|
|
|
|
|
|
|
|
_G.focus_tests = function()
|
|
|
|
local cmd = _G._build_test_cmd()
|
|
|
|
if cmd == nil then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local winid = _G._test_cmd_to_wins[cmd]
|
|
|
|
if winid == nil or not vim.api.nvim_win_is_valid(winid) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
vim.call("win_gotoid", winid)
|
2021-07-27 18:20:23 +00:00
|
|
|
vim.api.nvim_command([[wincmd =]])
|
2021-07-15 06:21:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
_G.close_tests = function()
|
|
|
|
local current_winid = vim.api.nvim_get_current_win()
|
|
|
|
for _, winid in pairs(_G._test_cmd_to_wins) do
|
|
|
|
if current_winid == winid and vim.api.nvim_win_is_valid(winid) then
|
|
|
|
vim.api.nvim_win_close(winid, false)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local cmd = _G._build_test_cmd()
|
|
|
|
if cmd == nil then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local winid = _G._test_cmd_to_wins[cmd]
|
|
|
|
if winid == nil or not vim.api.nvim_win_is_valid(winid) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
vim.api.nvim_win_close(winid, false)
|
|
|
|
end
|
|
|
|
|
|
|
|
_G.copy_test_cmd = function()
|
|
|
|
local cmd = _G._build_test_cmd()
|
|
|
|
if cmd == nil then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
vim.call("setreg", "*", cmd)
|
|
|
|
print("Copied: " .. cmd)
|
2021-07-14 16:00:28 +00:00
|
|
|
end
|
|
|
|
|
2021-07-15 06:21:56 +00:00
|
|
|
vim.api.nvim_set_keymap("n", "<leader>cr", [[:lua _G.run_tests()<cr>]], {noremap = true, silent = true})
|
|
|
|
vim.api.nvim_set_keymap("n", "<leader>cf", [[:lua _G.focus_tests()<cr>]], {noremap = true, silent = true})
|
|
|
|
vim.api.nvim_set_keymap("n", "<leader>cq", [[:lua _G.close_tests()<cr>]], {noremap = true, silent = true})
|
|
|
|
vim.api.nvim_set_keymap("n", "<leader>cc", [[:lua _G.copy_test_cmd()<cr>]], {noremap = true, silent = true})
|
2021-06-22 04:24:37 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
" Git mappings
|
|
|
|
"
|
|
|
|
" Copy Git permalink to clipboard for either current line or range
|
|
|
|
function! CopyGitURLToLineOrRange() range
|
|
|
|
if a:firstline == a:lastline
|
|
|
|
execute ".GBrowse!"
|
|
|
|
else
|
|
|
|
execute a:firstline . "," . a:lastline . "GBrowse!"
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! OpenGitURLToLineOrRange() range
|
|
|
|
if a:firstline == a:lastline
|
|
|
|
execute ".GBrowse"
|
|
|
|
else
|
|
|
|
execute a:firstline . "," . a:lastline . "GBrowse"
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
2021-07-27 07:05:29 +00:00
|
|
|
nnoremap <leader>as :Git<cr>
|
2021-06-22 04:24:37 +00:00
|
|
|
nnoremap <leader>ab :Git blame<cr>
|
|
|
|
nnoremap <leader>ac :Commits<cr>
|
|
|
|
nnoremap <leader>ah :GitGutterLineHighlightsToggle<cr>
|
|
|
|
nnoremap <leader>aY :call CopyGitURLToLineOrRange()<cr>
|
|
|
|
vnoremap <leader>aY :call CopyGitURLToLineOrRange()<cr>
|
|
|
|
nnoremap <leader>ao :call OpenGitURLToLineOrRange()<cr>
|
|
|
|
nnoremap <leader>ap :execute 'silent !ghpr <c-r><c-f>' \| redraw!<cr>
|
|
|
|
|
|
|
|
" echo filename of current buffer:
|
|
|
|
nmap <leader>fe :echom expand("%:p")<cr>
|
|
|
|
" yank filename of current buffer:
|
|
|
|
function! CopyToDefaultRegister()
|
|
|
|
let @" = expand("%:p")
|
|
|
|
echom expand("%:p")
|
|
|
|
endfunction
|
|
|
|
nmap <leader>fy :call CopyToDefaultRegister()<cr>
|
|
|
|
" and into + register:
|
|
|
|
function! CopyToSystemClipboard()
|
|
|
|
let @* = expand("%:p")
|
|
|
|
let @+ = expand("%:p")
|
|
|
|
echom expand("%:p")
|
|
|
|
endfunction
|
|
|
|
nmap <leader>fY :call CopyToSystemClipboard()<cr>
|
|
|
|
|
|
|
|
" disable Ex mode
|
|
|
|
nnoremap Q <Nop>
|
|
|
|
|
|
|
|
function! ToggleQuickFix()
|
|
|
|
if empty(filter(getwininfo(), 'v:val.quickfix'))
|
|
|
|
copen
|
|
|
|
else
|
|
|
|
cclose
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
nmap <silent> <leader>q :call ToggleQuickFix()<cr>
|
|
|
|
nmap <silent> <leader>l :lclose<cr>
|
|
|
|
|
|
|
|
" vim-markdown configuration:
|
|
|
|
let g:vim_markdown_conceal = 1
|
|
|
|
|
|
|
|
" fzf configuration:
|
|
|
|
let g:fzf_action = {
|
|
|
|
\ 'ctrl-t': 'tab split',
|
|
|
|
\ 'ctrl-s': 'split',
|
|
|
|
\ 'ctrl-v': 'vsplit' }
|
|
|
|
nmap <leader>t :Files<cr>
|
|
|
|
nmap <leader>T :GFiles<cr>
|
|
|
|
nmap <leader>b :Buffers<cr>
|
|
|
|
nmap <leader>gg :Rg<cr>
|
|
|
|
|
|
|
|
" Lightline configuration:
|
|
|
|
packadd! lightline.vim " https://github.com/itchyny/lightline.vim.git
|
|
|
|
set laststatus=2
|
|
|
|
|
|
|
|
function! LightlineLSPErrorText()
|
|
|
|
let l:count = luaeval("vim.lsp.diagnostic.get_count(0, [[Error]])")
|
|
|
|
if l:count == 0
|
|
|
|
return ''
|
|
|
|
endif
|
|
|
|
return l:count . 'E'
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! LightlineLSPWarningText()
|
|
|
|
let l:count = luaeval("vim.lsp.diagnostic.get_count(0, [[Warning]])")
|
|
|
|
if l:count == 0
|
|
|
|
return ''
|
|
|
|
endif
|
|
|
|
return l:count . 'W'
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! LightlineLSPInformationText()
|
|
|
|
let l:count = luaeval("vim.lsp.diagnostic.get_count(0, [[Information]])")
|
|
|
|
if l:count == 0
|
|
|
|
return ''
|
|
|
|
endif
|
|
|
|
return l:count . 'I'
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
let g:lightline = {
|
|
|
|
\ 'colorscheme': 'seoul256',
|
|
|
|
\ 'active': {
|
|
|
|
\ 'left': [ [ 'mode', 'paste' ],
|
|
|
|
\ [ 'readonly', 'filename', 'modified' ],
|
|
|
|
\ [ 'gitbranch' ], ['lsperror', 'lspwarn', 'lspinfo' ] ],
|
|
|
|
\ 'right': [ ['lineinfo'], ['percent'], ['filetype'], ['gobuild'] ],
|
|
|
|
\ },
|
|
|
|
\ 'component_function': {
|
|
|
|
\ 'gobuild': 'go#statusline#Show',
|
|
|
|
\ 'gitbranch': 'FugitiveStatusline',
|
|
|
|
\ },
|
|
|
|
\ 'component_expand': {
|
|
|
|
\ 'lsperror': 'LightlineLSPErrorText',
|
|
|
|
\ 'lspwarn': 'LightlineLSPWarningText',
|
|
|
|
\ 'lspinfo': 'LightlineLSPInformationText',
|
|
|
|
\ },
|
|
|
|
\ 'component_type': {
|
|
|
|
\ 'lsperror': 'error',
|
|
|
|
\ 'lspwarn': 'warning',
|
|
|
|
\ },
|
|
|
|
\ 'mode_map': {
|
|
|
|
\ 'n' : 'N',
|
|
|
|
\ 'i' : 'I',
|
|
|
|
\ 'R' : 'R',
|
|
|
|
\ 'v' : 'V',
|
|
|
|
\ 'V' : 'V-LINE',
|
|
|
|
\ "\<C-v>": 'V-BLOCK',
|
|
|
|
\ 'c' : 'C',
|
|
|
|
\ 's' : 'S',
|
|
|
|
\ 'S' : 'S-LINE',
|
|
|
|
\ "\<C-s>": 'S-BLOCK',
|
|
|
|
\ 't': 'TERM',
|
|
|
|
\ },
|
|
|
|
\ }
|
|
|
|
|
|
|
|
" vim-gitgutter configuration
|
|
|
|
packadd! vim-gitgutter " https://github.com/airblade/vim-gitgutter.git
|
|
|
|
set signcolumn=yes
|
|
|
|
nmap ]h <Plug>(GitGutterNextHunk)
|
|
|
|
nmap [h <Plug>(GitGutterPrevHunk)
|
|
|
|
omap ih <Plug>(GitGutterTextObjectInnerPending)
|
|
|
|
omap ah <Plug>(GitGutterTextObjectOuterPending)
|
|
|
|
xmap ih <Plug>(GitGutterTextObjectInnerVisual)
|
|
|
|
xmap ah <Plug>(GitGutterTextObjectOuterVisual)
|
|
|
|
|
|
|
|
" vim-fugitive
|
|
|
|
packadd! vim-fugitive " https://github.com/tpope/vim-fugitive.git
|
|
|
|
|
|
|
|
" vim-go
|
|
|
|
" Doesn't work in after/ftplugin/go.vim:
|
|
|
|
let g:go_def_mapping_enabled = 0
|
|
|
|
packadd! vim-go " https://github.com/fatih/vim-go.git
|
|
|
|
|
|
|
|
" load internal plugins:
|
|
|
|
runtime macros/matchit.vim
|
|
|
|
|
|
|
|
" load other plugins:
|
|
|
|
packadd! rust.vim " https://github.com/rust-lang/rust.vim.git
|
|
|
|
packadd! tmux-complete.vim " https://github.com/wellle/tmux-complete.vim.git
|
|
|
|
packadd! vim-commentary " https://github.com/tpope/vim-commentary.git
|
2021-07-14 16:00:43 +00:00
|
|
|
packadd! vim-rails " https://github.com/tpope/vim-rails.git
|
2021-06-22 04:24:37 +00:00
|
|
|
|
|
|
|
" Requires both fzf.vim plugin to be manually installed:
|
|
|
|
" https://github.com/junegunn/fzf/blob/master/plugin/fzf.vim
|
|
|
|
" and also this separate plugin, which is loaded here:
|
|
|
|
packadd! fzf.vim " https://github.com/junegunn/fzf.vim.git
|
|
|
|
packadd! vim-surround " https://github.com/tpope/vim-surround.git
|
|
|
|
packadd! vim-rhubarb " https://github.com/tpope/vim-rhubarb.git
|
|
|
|
packadd! editorconfig-vim " https://github.com/editorconfig/editorconfig-vim.git
|
|
|
|
packadd! vim-wordmotion " https://github.com/chaoren/vim-wordmotion.git
|
|
|
|
|
|
|
|
" enable inline vim highlighting:
|
|
|
|
let g:vimsyn_embed= 'lPr'
|
|
|
|
|
|
|
|
" Treesitter
|
|
|
|
|
|
|
|
packadd! nvim-treesitter " https://github.com/nvim-treesitter/nvim-treesitter.git
|
|
|
|
packadd! nvim-treesitter-textobjects " https://github.com/nvim-treesitter/nvim-treesitter-textobjects.git
|
|
|
|
packadd! nvim-treesitter-refactor " https://github.com/nvim-treesitter/nvim-treesitter-refactor.git
|
|
|
|
packadd! playground " https://github.com/nvim-treesitter/playground.git
|
|
|
|
|
|
|
|
lua <<EOF
|
|
|
|
require 'nvim-treesitter.configs'.setup {
|
|
|
|
ensure_installed = "maintained",
|
|
|
|
highlight = {
|
|
|
|
enable = true,
|
|
|
|
},
|
|
|
|
incremental_selection = {
|
|
|
|
enable = true,
|
|
|
|
},
|
|
|
|
indent = {
|
|
|
|
enable = false,
|
|
|
|
},
|
|
|
|
textobjects = {
|
|
|
|
select = {
|
|
|
|
enable = true,
|
|
|
|
lookahead = true,
|
|
|
|
keymaps = {
|
|
|
|
["ak"] = "@keyed_element.outer",
|
|
|
|
["av"] = "@keyed_element.inner",
|
|
|
|
["ia"] = "@parameter.inner",
|
|
|
|
["aa"] = "@parameter.outer",
|
|
|
|
["ac"] = "@comment.outer",
|
|
|
|
["at"] = "@statement.outer",
|
|
|
|
["ar"] = "@return",
|
|
|
|
["af"] = "@function.outer",
|
|
|
|
["if"] = "@function.inner",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
move = {
|
|
|
|
enable = true,
|
|
|
|
set_jumps = true,
|
|
|
|
goto_next_start = {
|
|
|
|
["]a"] = "@parameter.inner",
|
|
|
|
["]f"] = "@function.outer",
|
|
|
|
["]F"] = "@function.inner",
|
|
|
|
},
|
|
|
|
goto_previous_start = {
|
|
|
|
["[a"] = "@parameter.inner",
|
|
|
|
["[f"] = "@function.outer",
|
|
|
|
["[F"] = "@function.inner",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
refactor = {
|
|
|
|
-- TODO: navigation broken.
|
|
|
|
navigation = {
|
|
|
|
enable = true,
|
|
|
|
keymaps = {
|
|
|
|
goto_next_usage = "]r",
|
|
|
|
goto_previous_usage = "[r",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
lsp_interop = {
|
|
|
|
enable = true,
|
|
|
|
peek_definition_code = {
|
|
|
|
["<leader>d"] = "@class.outer",
|
|
|
|
["<leader>d"] = "@function.outer",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
playground = {
|
|
|
|
enable = true,
|
|
|
|
disable = {},
|
|
|
|
updatetime = 25,
|
|
|
|
persist_queries = false,
|
|
|
|
keybindings = {
|
|
|
|
toggle_query_editor = 'o',
|
|
|
|
toggle_hl_groups = 'i',
|
|
|
|
toggle_injected_languages = 't',
|
|
|
|
toggle_anonymous_nodes = 'a',
|
|
|
|
toggle_language_display = 'I',
|
|
|
|
focus_language = 'f',
|
|
|
|
unfocus_language = 'F',
|
|
|
|
update = 'R',
|
|
|
|
goto_node = '<cr>',
|
|
|
|
show_help = '?',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
" LSP
|
|
|
|
|
|
|
|
packadd! nvim-lspconfig " https://github.com/neovim/nvim-lspconfig.git
|
|
|
|
packadd! lsp_signature.nvim " https://github.com/ray-x/lsp_signature.nvim.git
|
|
|
|
packadd! fzf-lsp.nvim " https://github.com/gfanto/fzf-lsp.nvim.git
|
|
|
|
|
|
|
|
lua <<EOF
|
|
|
|
local nvim_lsp = require('lspconfig')
|
|
|
|
local on_attach = function(client, bufnr)
|
|
|
|
-- nvim does not expose autocmd via Lua API yet:
|
|
|
|
vim.api.nvim_exec([[autocmd User LspDiagnosticsChanged call lightline#update()]], false)
|
|
|
|
|
|
|
|
local opts = { noremap=true, silent=false }
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<Cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>gD', '<Cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>e', '<Cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>r', '<Cmd>lua vim.lsp.buf.references()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>i', '<Cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<Cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ci', '<Cmd>lua vim.lsp.buf.incoming_calls()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>co', '<Cmd>lua vim.lsp.buf.outgoing_calls()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']e', '<Cmd>lua vim.lsp.diagnostic.goto_next({severity="Error"})<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[e', '<Cmd>lua vim.lsp.diagnostic.goto_prev({severity="Error"})<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']d', '<Cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[d', '<Cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'cd', '<Cmd>lua vim.lsp.diagnostic.clear(0)<CR>', opts)
|
|
|
|
|
|
|
|
-- fzf triggers:
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>fr', '<Cmd>References<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>fi', '<Cmd>Implementations<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>fs', '<Cmd>DocumentSymbols<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>fw', '<Cmd>WorkspaceSymbols<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>fc', '<Cmd>CodeActions<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>fci', '<Cmd>IncomingCalls<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>fco', '<Cmd>OutgoingCalls<CR>', opts)
|
|
|
|
|
|
|
|
require 'lsp_signature'.on_attach({
|
|
|
|
hint_enable = false,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Go
|
|
|
|
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
|
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
|
|
capabilities.textDocument.completion.completionItem.resolveSupport = {
|
|
|
|
properties = {
|
|
|
|
'documentation',
|
|
|
|
'detail',
|
|
|
|
'additionalTextEdits',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nvim_lsp.gopls.setup{
|
|
|
|
settings = {
|
|
|
|
gopls = {
|
|
|
|
staticcheck = true,
|
|
|
|
analyses = {
|
|
|
|
unusedparams = true,
|
|
|
|
shadow = true,
|
|
|
|
unusedwrite = true,
|
|
|
|
unusedresult = true,
|
|
|
|
nilness = true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
capabilities = capabilities,
|
|
|
|
on_attach = on_attach,
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Ruby
|
|
|
|
|
|
|
|
nvim_lsp.solargraph.setup{
|
|
|
|
on_attach = on_attach,
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Lua
|
|
|
|
|
|
|
|
local system_name
|
|
|
|
if vim.fn.has("mac") == 1 then
|
|
|
|
system_name = "macOS"
|
|
|
|
elseif vim.fn.has("unix") == 1 then
|
|
|
|
system_name = "Linux"
|
|
|
|
else
|
|
|
|
print("Unsupported system for sumneko")
|
|
|
|
end
|
|
|
|
|
|
|
|
local sumneko_root_path = os.getenv("HOME").."/dev/lua-language-server"
|
|
|
|
local sumneko_binary = sumneko_root_path.."/bin/"..system_name.."/lua-language-server"
|
|
|
|
|
|
|
|
local runtime_path = vim.split(package.path, ';')
|
|
|
|
table.insert(runtime_path, "lua/?.lua")
|
|
|
|
table.insert(runtime_path, "lua/?/init.lua")
|
|
|
|
|
|
|
|
nvim_lsp.sumneko_lua.setup {
|
|
|
|
cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"};
|
|
|
|
settings = {
|
|
|
|
Lua = {
|
|
|
|
runtime = {
|
|
|
|
version = 'LuaJIT',
|
|
|
|
path = runtime_path,
|
|
|
|
},
|
|
|
|
diagnostics = {
|
|
|
|
globals = {'vim'},
|
|
|
|
},
|
|
|
|
workspace = {
|
|
|
|
library = vim.api.nvim_get_runtime_file("", true),
|
|
|
|
},
|
|
|
|
telemetry = {
|
|
|
|
enable = false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
on_attach = on_attach,
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
" nvim-compe:
|
|
|
|
|
|
|
|
packadd! nvim-compe " https://github.com/hrsh7th/nvim-compe
|
|
|
|
packadd! compe-tmux " https://github.com/andersevenrud/compe-tmux
|
|
|
|
|
|
|
|
lua <<EOF
|
|
|
|
require 'compe'.setup {
|
|
|
|
enabled = true;
|
|
|
|
autocomplete = true;
|
|
|
|
debug = false;
|
|
|
|
min_length = 1;
|
|
|
|
preselect = 'enable';
|
|
|
|
throttle_time = 80;
|
|
|
|
source_timeout = 200;
|
|
|
|
resolve_timeout = 800;
|
|
|
|
incomplete_delay = 400;
|
|
|
|
max_abbr_width = 100;
|
|
|
|
max_kind_width = 100;
|
|
|
|
max_menu_width = 100;
|
|
|
|
documentation = true;
|
|
|
|
|
|
|
|
source = {
|
|
|
|
path = true;
|
|
|
|
buffer = true;
|
|
|
|
calc = true;
|
|
|
|
nvim_lsp = true;
|
|
|
|
nvim_lua = true;
|
|
|
|
vsnip = false;
|
|
|
|
ultisnips = false;
|
|
|
|
tmux = true;
|
|
|
|
treesitter = false;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2021-07-20 07:52:24 +00:00
|
|
|
inoremap <silent><expr> <C-y> compe#confirm('<C-y>')
|
|
|
|
inoremap <silent><expr> <C-e> compe#close('<C-e>')
|
|
|
|
inoremap <silent><expr> <C-f> compe#scroll({ 'delta': +4 })
|
|
|
|
inoremap <silent><expr> <C-d> compe#scroll({ 'delta': -4 })
|
2021-06-22 04:24:37 +00:00
|
|
|
|
|
|
|
" TAB navigation support:
|
|
|
|
lua <<EOF
|
|
|
|
local t = function(str)
|
|
|
|
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
|
|
|
end
|
|
|
|
|
|
|
|
local check_back_space = function()
|
|
|
|
local col = vim.fn.col('.') - 1
|
|
|
|
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
_G.tab_complete = function()
|
|
|
|
if vim.fn.pumvisible() == 1 then
|
|
|
|
return t "<C-n>"
|
|
|
|
elseif check_back_space() then
|
|
|
|
return t "<Tab>"
|
|
|
|
else
|
|
|
|
return vim.fn['compe#complete']()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
_G.s_tab_complete = function()
|
|
|
|
if vim.fn.pumvisible() == 1 then
|
|
|
|
return t "<C-p>"
|
|
|
|
else
|
|
|
|
return t "<S-Tab>"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
|
|
|
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
|
|
|
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
|
|
|
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
|
|
|
EOF
|