2020-02-24 19:09:16 -07:00
|
|
|
scriptencoding utf-8
|
|
|
|
|
2017-02-22 21:49:21 -07:00
|
|
|
" vim-plug---START
|
|
|
|
call plug#begin('~/.config/nvim/plugged')
|
|
|
|
|
2020-02-24 19:09:16 -07:00
|
|
|
|
2017-02-22 21:49:21 -07:00
|
|
|
" Plugins
|
|
|
|
Plug 'airblade/vim-gitgutter'
|
2019-01-30 11:30:13 -07:00
|
|
|
Plug 'cespare/vim-toml'
|
2020-02-02 12:12:50 -07:00
|
|
|
Plug 'vim-scripts/nginx.vim'
|
2019-10-04 08:44:36 -07:00
|
|
|
Plug 'elixir-lang/vim-elixir'
|
2018-03-11 00:22:12 -07:00
|
|
|
Plug 'fatih/vim-go'
|
2018-10-05 07:47:53 -07:00
|
|
|
Plug 'gabesoft/vim-ags'
|
2021-06-15 07:34:48 -07:00
|
|
|
Plug 'google/protobuf'
|
2019-01-30 11:30:13 -07:00
|
|
|
Plug 'hashivim/vim-terraform'
|
2022-08-08 08:12:48 -07:00
|
|
|
Plug 'hrsh7th/cmp-buffer'
|
|
|
|
Plug 'hrsh7th/cmp-calc'
|
|
|
|
Plug 'hrsh7th/cmp-nvim-lsp'
|
|
|
|
Plug 'hrsh7th/cmp-nvim-lua'
|
|
|
|
Plug 'hrsh7th/cmp-path'
|
|
|
|
Plug 'hrsh7th/cmp-vsnip'
|
|
|
|
Plug 'hrsh7th/nvim-cmp'
|
|
|
|
Plug 'hrsh7th/vim-vsnip'
|
2023-01-12 14:31:34 -07:00
|
|
|
Plug 'junegunn/fzf'
|
2017-06-22 13:24:12 -07:00
|
|
|
Plug 'kchmck/vim-coffee-script'
|
2020-02-24 18:27:04 -07:00
|
|
|
Plug 'lifepillar/vim-solarized8'
|
2017-02-22 21:49:21 -07:00
|
|
|
Plug 'majutsushi/tagbar'
|
2021-08-05 12:42:06 -07:00
|
|
|
Plug 'neovim/nvim-lspconfig'
|
2022-01-07 06:16:27 -07:00
|
|
|
Plug 'OmniSharp/omnisharp-vim'
|
2017-08-23 08:13:13 -07:00
|
|
|
Plug 'posva/vim-vue'
|
2022-11-15 13:35:17 -07:00
|
|
|
Plug 'sainnhe/gruvbox-material'
|
2017-02-27 10:16:29 -07:00
|
|
|
Plug 'scrooloose/nerdcommenter'
|
2017-02-22 21:49:21 -07:00
|
|
|
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
|
2022-01-07 06:16:27 -07:00
|
|
|
Plug 'Shougo/vimproc.vim'
|
|
|
|
Plug 'tpope/vim-dispatch'
|
2017-02-22 21:49:21 -07:00
|
|
|
Plug 'tpope/vim-fugitive'
|
|
|
|
Plug 'tpope/vim-rails'
|
|
|
|
Plug 'tpope/vim-surround'
|
|
|
|
|
|
|
|
call plug#end()
|
|
|
|
|
|
|
|
" vim-plug---END
|
|
|
|
|
|
|
|
syntax enable
|
2020-02-24 18:27:04 -07:00
|
|
|
set termguicolors
|
2022-11-15 13:35:17 -07:00
|
|
|
colorscheme gruvbox-material
|
2017-09-08 08:47:42 -07:00
|
|
|
set cursorline
|
|
|
|
set colorcolumn=80,100
|
2017-05-05 09:53:15 -07:00
|
|
|
|
2020-02-24 18:27:04 -07:00
|
|
|
function ToggleBackground(current)
|
2020-02-24 19:09:16 -07:00
|
|
|
if a:current ==# 'dark'
|
2020-02-24 18:27:04 -07:00
|
|
|
set background=light
|
2022-11-15 13:35:17 -07:00
|
|
|
" hi Whitespace ctermfg=7 guifg=#eee8d5
|
2017-05-05 09:55:57 -07:00
|
|
|
else
|
2020-02-24 18:27:04 -07:00
|
|
|
set background=dark
|
2022-11-15 13:35:17 -07:00
|
|
|
" hi Whitespace ctermfg=0 guifg=#073642
|
2017-05-05 09:55:57 -07:00
|
|
|
end
|
|
|
|
endfunction
|
|
|
|
|
2020-02-24 19:09:16 -07:00
|
|
|
call ToggleBackground('light')
|
2020-02-24 18:27:04 -07:00
|
|
|
nmap <F5> :call ToggleBackground(&background)<CR>
|
2017-05-05 09:55:57 -07:00
|
|
|
|
2018-07-26 22:04:05 -07:00
|
|
|
set spell
|
2017-05-05 09:53:15 -07:00
|
|
|
set number
|
2017-02-22 21:49:21 -07:00
|
|
|
set nowrap
|
|
|
|
filetype plugin indent on
|
|
|
|
|
2017-07-27 08:38:36 -07:00
|
|
|
set mouse=a
|
|
|
|
|
2017-02-22 21:49:21 -07:00
|
|
|
set list
|
2017-05-17 08:23:56 -07:00
|
|
|
set listchars=tab:――,space:·,trail:·
|
2017-02-22 21:49:21 -07:00
|
|
|
|
2020-02-24 19:09:16 -07:00
|
|
|
let g:NoClean = ['diff']
|
2018-12-13 08:24:01 -07:00
|
|
|
|
2020-11-19 06:28:11 -07:00
|
|
|
augroup indentation
|
|
|
|
autocmd BufRead,BufNewFile
|
|
|
|
\ Makefile,
|
|
|
|
\*.c,
|
|
|
|
\*.cpp,
|
|
|
|
\*.go
|
|
|
|
\ set tabstop=8 shiftwidth=8 noexpandtab
|
|
|
|
|
|
|
|
|
|
|
|
autocmd BufRead,BufNewFile
|
|
|
|
\ *.cs,
|
|
|
|
\*.java
|
|
|
|
\ set tabstop=4 shiftwidth=4 expandtab
|
|
|
|
|
|
|
|
autocmd BufRead,BufNewFile
|
|
|
|
\ *.rb,
|
|
|
|
\*.css,
|
|
|
|
\*.js,
|
|
|
|
\*.jsx,
|
|
|
|
\*.coffee,
|
|
|
|
\*.erb,
|
|
|
|
\*.html,
|
|
|
|
\*.html.tmpl,
|
|
|
|
\*.json,
|
2022-10-24 14:25:36 -07:00
|
|
|
\*.qtpl,
|
2020-11-19 06:28:11 -07:00
|
|
|
\*.tf,
|
|
|
|
\*.tfvars,
|
|
|
|
\*.vue,
|
|
|
|
\*.yml,
|
|
|
|
\*.yaml
|
|
|
|
\ set tabstop=2 shiftwidth=2 expandtab
|
2018-11-27 09:17:01 -07:00
|
|
|
|
2017-05-17 08:23:12 -07:00
|
|
|
autocmd FileType crontab set backupcopy=yes
|
2017-02-22 21:49:21 -07:00
|
|
|
|
2020-02-24 19:09:16 -07:00
|
|
|
augroup END
|
|
|
|
|
|
|
|
" vint: -ProhibitCommandRelyOnUser -ProhibitCommandWithUnintendedSideEffect
|
|
|
|
|
2017-02-22 21:49:21 -07:00
|
|
|
function TrimTrailingInvisibles()
|
|
|
|
let view = winsaveview()
|
|
|
|
%s/\s\+$//e
|
|
|
|
call winrestview(view)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function TrimTrailingLines()
|
|
|
|
let view = winsaveview()
|
|
|
|
%s/\n\+\%$//e
|
|
|
|
call winrestview(view)
|
|
|
|
endfunction
|
|
|
|
|
2020-02-24 19:09:16 -07:00
|
|
|
" vint: +ProhibitCommandRelyOnUser +ProhibitCommandWithUnintendedSideEffect
|
|
|
|
|
2018-12-13 08:22:59 -07:00
|
|
|
function OnWrite()
|
|
|
|
if Writeable()
|
|
|
|
call CleanFile()
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function OnLeave()
|
|
|
|
if Writeable()
|
|
|
|
call CleanFile()
|
|
|
|
write
|
|
|
|
GitGutter
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function CleanFile()
|
|
|
|
call TrimTrailingInvisibles() | call TrimTrailingLines()
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function Writeable()
|
2020-02-24 19:09:16 -07:00
|
|
|
return empty(&buftype)
|
2018-12-13 08:24:01 -07:00
|
|
|
\ && index(g:NoClean, &filetype) == -1
|
2018-12-13 08:22:59 -07:00
|
|
|
\ && !&readonly
|
|
|
|
\ && &modifiable
|
|
|
|
\ && &modified
|
2020-02-24 19:09:16 -07:00
|
|
|
\ && !empty(expand('%:t'))
|
2018-12-13 08:22:59 -07:00
|
|
|
endfunction
|
|
|
|
|
2017-02-22 21:49:21 -07:00
|
|
|
augroup maximus
|
|
|
|
|
2018-12-13 08:22:59 -07:00
|
|
|
autocmd BufWrite * call OnWrite()
|
|
|
|
autocmd BufLeave * call OnLeave()
|
2017-02-22 21:49:21 -07:00
|
|
|
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
set statusline=%f
|
|
|
|
set statusline+=\ %y
|
|
|
|
set statusline+=[%{&ff}]
|
|
|
|
set statusline+=%r
|
|
|
|
set statusline+=%h
|
|
|
|
set statusline+=%{ModifiedSym()}
|
|
|
|
set statusline+=%=
|
|
|
|
set statusline+=%{AddGitGutterToStatusline()}
|
|
|
|
set statusline+=\ [%c:%l/%L:%p%%]
|
|
|
|
|
|
|
|
function ModifiedSym()
|
|
|
|
if &modified
|
|
|
|
return "[\u270f]"
|
|
|
|
else
|
2020-02-24 19:09:16 -07:00
|
|
|
return ''
|
2017-02-22 21:49:21 -07:00
|
|
|
end
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function AddGitGutterToStatusline()
|
2020-02-24 19:09:16 -07:00
|
|
|
if empty(&buftype) && exists('b:gitgutter_summary')
|
|
|
|
return join(['[Git:', join(b:gitgutter_summary, ','), ']'], '')
|
2017-02-22 21:49:21 -07:00
|
|
|
else
|
2020-02-24 19:09:16 -07:00
|
|
|
return ''
|
2017-02-22 21:49:21 -07:00
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Shortcuts
|
2017-05-22 14:18:38 -07:00
|
|
|
" Plugins
|
2018-12-13 08:40:13 -07:00
|
|
|
nnoremap <C-\> :NERDTreeToggle<CR>
|
|
|
|
nnoremap <leader>. :TagbarToggle<CR>
|
2017-02-22 21:49:21 -07:00
|
|
|
|
2017-05-22 14:18:38 -07:00
|
|
|
" Tabs
|
2018-12-13 08:40:13 -07:00
|
|
|
nnoremap <leader>tt :tabnew<CR>
|
|
|
|
nnoremap <leader>tn :tabnext<CR>
|
|
|
|
nnoremap <leader>tp :tabprevious<CR>
|
|
|
|
nnoremap <leader>tc :tabclose<CR>
|
|
|
|
nnoremap <leader>tm :tabmove<CR>
|
2017-05-22 14:18:38 -07:00
|
|
|
|
2017-06-22 13:24:26 -07:00
|
|
|
" Misc
|
2018-12-13 08:40:13 -07:00
|
|
|
nnoremap <leader>h :noh<CR>
|
2018-12-13 08:41:04 -07:00
|
|
|
nnoremap <C-]> :exec "tjump ".expand("<cword>")<CR>
|
2018-12-12 16:07:51 -07:00
|
|
|
nnoremap <leader><space> :call Fullscreen()<CR>
|
|
|
|
|
|
|
|
function Fullscreen()
|
|
|
|
let view = winsaveview()
|
|
|
|
let buf = winbufnr(0)
|
|
|
|
let found = 0
|
|
|
|
|
|
|
|
for b in win_findbuf(buf)
|
|
|
|
let tabwin = win_id2tabwin(b)
|
2020-02-24 19:09:16 -07:00
|
|
|
if gettabwinvar(tabwin[0], tabwin[1], 'fullscreen_buf') == buf
|
2018-12-12 16:07:51 -07:00
|
|
|
let found = 1
|
|
|
|
let existing_tab = tabwin[0]
|
|
|
|
let existing_win = tabwin[1]
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
if found == 1
|
|
|
|
if existing_tab == tabpagenr()
|
|
|
|
tabclose
|
|
|
|
else
|
2020-02-24 19:09:16 -07:00
|
|
|
exec 'tabnext'.existing_tab
|
2018-12-12 16:07:51 -07:00
|
|
|
endif
|
|
|
|
else
|
2020-02-24 19:09:16 -07:00
|
|
|
exec 'tabnew +buffer'.buf
|
2018-12-12 16:07:51 -07:00
|
|
|
let w:fullscreen_buf = buf
|
|
|
|
end
|
|
|
|
|
|
|
|
call winrestview(view)
|
|
|
|
endfunction
|
2017-06-22 13:24:26 -07:00
|
|
|
|
2017-02-22 21:49:21 -07:00
|
|
|
" Plugin configuration
|
2018-10-05 07:47:53 -07:00
|
|
|
|
|
|
|
" The Silver Searcher
|
2018-12-13 08:40:13 -07:00
|
|
|
nnoremap <leader>s :Ags<space>
|
2018-10-05 07:47:53 -07:00
|
|
|
|
|
|
|
" FZF
|
2022-12-23 07:43:16 -07:00
|
|
|
nnoremap <C-p> :FZF<CR>
|
2017-05-01 14:52:00 -07:00
|
|
|
|
2017-02-27 10:16:29 -07:00
|
|
|
" NERD Commenter
|
|
|
|
let g:NERDSpaceDelims = 1
|
|
|
|
|
2018-08-07 08:55:36 -07:00
|
|
|
" NERD Tree
|
|
|
|
let g:NERDTreeShowHidden = 1
|
|
|
|
|
2017-12-21 19:16:38 -07:00
|
|
|
" Tagbar
|
|
|
|
let g:tagbar_type_go = {
|
|
|
|
\ 'ctagstype' : 'go',
|
|
|
|
\ 'kinds' : [
|
|
|
|
\ 'p:package',
|
|
|
|
\ 'i:imports:1',
|
|
|
|
\ 'c:constants',
|
|
|
|
\ 'v:variables',
|
|
|
|
\ 't:types',
|
|
|
|
\ 'n:interfaces',
|
|
|
|
\ 'w:fields',
|
|
|
|
\ 'e:embedded',
|
|
|
|
\ 'm:methods',
|
|
|
|
\ 'r:constructor',
|
|
|
|
\ 'f:functions'
|
|
|
|
\ ],
|
|
|
|
\ 'sro' : '.',
|
|
|
|
\ 'kind2scope' : {
|
|
|
|
\ 't' : 'ctype',
|
|
|
|
\ 'n' : 'ntype'
|
|
|
|
\ },
|
|
|
|
\ 'scope2kind' : {
|
|
|
|
\ 'ctype' : 't',
|
|
|
|
\ 'ntype' : 'n'
|
|
|
|
\ },
|
|
|
|
\ 'ctagsbin' : 'gotags',
|
|
|
|
\ 'ctagsargs' : '-sort -silent'
|
|
|
|
\ }
|
2021-08-05 12:42:06 -07:00
|
|
|
|
2022-08-08 08:12:48 -07:00
|
|
|
set completeopt=menu,menuone,noselect
|
|
|
|
|
2021-08-05 12:42:06 -07:00
|
|
|
lua <<EOF
|
2022-01-07 06:16:37 -07:00
|
|
|
local on_attach = function(client, bufnr)
|
|
|
|
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
|
|
|
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
|
|
|
|
|
|
|
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
|
|
|
|
|
|
local opts = { noremap=true, silent=true }
|
|
|
|
|
|
|
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
|
|
|
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
|
|
|
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
|
|
|
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
|
|
|
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
|
|
|
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
|
|
|
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
|
|
|
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
|
|
|
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
|
|
|
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
|
|
|
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
|
|
|
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
|
|
|
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
|
|
|
buf_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
|
|
|
|
buf_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
|
|
|
|
buf_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
|
|
|
|
buf_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
|
|
|
|
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
2022-08-08 08:12:48 -07:00
|
|
|
|
|
|
|
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
2022-01-07 06:16:37 -07:00
|
|
|
end
|
|
|
|
|
2022-08-08 08:12:48 -07:00
|
|
|
local cmp = require'cmp'
|
|
|
|
|
|
|
|
local sources = {
|
|
|
|
{ name = 'nvim_lsp' },
|
|
|
|
{ name = 'nvim_lua' },
|
2023-01-10 07:15:04 -07:00
|
|
|
{ name = 'vsnip' },
|
|
|
|
{ name = 'path' },
|
2022-08-08 08:12:48 -07:00
|
|
|
{ name = 'buffer' },
|
|
|
|
}
|
|
|
|
|
|
|
|
cmp.setup({
|
|
|
|
snippet = {
|
|
|
|
expand = function(args)
|
|
|
|
vim.fn["vsnip#anonymous"](args.body)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
mapping = cmp.mapping.preset.insert({
|
|
|
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
|
|
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
|
|
|
}),
|
|
|
|
sources = cmp.config.sources(sources),
|
|
|
|
})
|
|
|
|
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
2023-01-10 07:12:45 -07:00
|
|
|
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
2022-08-08 08:12:48 -07:00
|
|
|
|
2022-01-07 06:16:37 -07:00
|
|
|
require'lspconfig'.gopls.setup{
|
2022-08-08 08:12:48 -07:00
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
2022-01-07 06:16:37 -07:00
|
|
|
}
|
2022-08-08 08:12:48 -07:00
|
|
|
|
2021-08-05 12:42:06 -07:00
|
|
|
require'lspconfig'.solargraph.setup{
|
2022-08-08 08:12:48 -07:00
|
|
|
on_attach = on_attach,
|
|
|
|
bundlerPath = 'bin/bundle',
|
|
|
|
useBundler = true,
|
|
|
|
capabilities = capabilities,
|
2021-08-05 12:42:06 -07:00
|
|
|
}
|
2022-08-08 08:12:48 -07:00
|
|
|
|
2022-01-07 06:16:37 -07:00
|
|
|
require'lspconfig'.rust_analyzer.setup{
|
2022-08-08 08:12:48 -07:00
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
}
|
|
|
|
|
|
|
|
require'lspconfig'.clangd.setup{
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
2022-01-07 06:16:37 -07:00
|
|
|
}
|
2021-08-05 12:42:06 -07:00
|
|
|
EOF
|