Created
April 6, 2022 22:28
-
-
Save delabere/570ba393da3a994962770e4ea5ee1dfe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mapleader = " " | |
filetype on | |
filetype indent on | |
filetype plugin on | |
set encoding=UTF-8 | |
syntax on | |
set nocompatible | |
set hlsearch | |
set number relativenumber | |
set laststatus=2 | |
set vb | |
set ruler | |
set spelllang=en_us | |
set autoindent | |
set colorcolumn=120 | |
set mouse=a | |
set clipboard=unnamed | |
set noscrollbind | |
set wildmenu | |
set autochdir | |
set scrolloff=8 | |
hi Search cterm=NONE ctermfg=black ctermbg=red | |
" lets you use 'kj' instead of <Esc> | |
inoremap kj <Esc> | |
" No more Arrow Keys, deal with it | |
noremap <Up> <NOP> | |
noremap <Down> <NOP> | |
noremap <Left> <NOP> | |
noremap <Right> <NOP> | |
" Use ctrl-[hjkl] to select the active split! | |
nmap <silent> <c-k> :wincmd k<CR> | |
nmap <silent> <c-j> :wincmd j<CR> | |
nmap <silent> <c-h> :wincmd h<CR> | |
nmap <silent> <c-l> :wincmd l<CR> | |
" source the configuration file on the fly | |
nnoremap <leader><CR> :so ~/.config/nvim/init.vim<CR> " | |
" plug | |
call plug#begin() | |
"> Must Have | |
Plug 'vim-airline/vim-airline' " https://github.com/vim-airline/vim-airline | |
Plug 'ctrlpvim/ctrlp.vim' " https://github.com/ctrlpvim/ctrlp.vim | |
Plug 'ryanoasis/vim-devicons' " https://github.com/ryanoasis/vim-devicons + https://github.com/ryanoasis/nerd-fonts/ | |
Plug 'tpope/vim-commentary' " https://github.com/tpope/vim-commentary | |
Plug 'airblade/vim-gitgutter' " https://github.com/airblade/vim-gitgutter | |
Plug 'mkitt/tabline.vim' " https://github.com/mkitt/tabline.vim | |
"> Go | |
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' } " https://github.com/fatih/vim-go | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} " https://github.com/neoclide/coc.nvim | |
" telescope fuzzy finder | |
Plug 'nvim-lua/plenary.nvim' | |
Plug 'nvim-telescope/telescope.nvim' | |
" nvim-tree | |
Plug 'kyazdani42/nvim-web-devicons' " for file icons | |
Plug 'kyazdani42/nvim-tree.lua' | |
" Monzo nvin plugin | |
Plug 'neovim/nvim-lspconfig' | |
Plug '~/src/github.com/monzo/wearedev/tools/editors/nvim/nvim-monzo' | |
Plug 'jiangmiao/auto-pairs' " automatically insert/delete bracket pairs | |
" Themes | |
Plug 'NLKNguyen/papercolor-theme' " https://github.com/NLKNguyen/papercolor-theme | |
Plug 'morhetz/gruvbox' " a different theme | |
call plug#end() | |
"-- plug END | |
"-- vim-go specific configuration | |
" run :GoBuild or :GoTestCompile based on the go file | |
function! s:build_go_files() | |
let l:file = expand('%') | |
if l:file =~# '^\f\+_test\.go$' | |
call go#test#Test(0, 1) | |
elseif l:file =~# '^\f\+\.go$' | |
call go#cmd#Build(0) | |
endif | |
endfunction | |
autocmd FileType go nmap <leader>b :<C-u>call <SID>build_go_files()<CR> | |
autocmd FileType go nmap <Leader>c <Plug>(go-coverage-toggle) | |
autocmd FileType go nmap <leader>t <Plug>(go-test) | |
autocmd Filetype go command! -bang A call go#alternate#Switch(<bang>0, 'edit') | |
autocmd Filetype go command! -bang AV call go#alternate#Switch(<bang>0, 'vsplit') | |
autocmd Filetype go command! -bang AS call go#alternate#Switch(<bang>0, 'split') | |
autocmd Filetype go command! -bang AT call go#alternate#Switch(<bang>0, 'tabe') | |
autocmd FileType go setlocal foldmethod=expr foldexpr=getline(v:lnum)=~'^\s*'.&commentstring[0] | |
let g:go_list_type = "quickfix" " error lists are of type quickfix | |
let g:go_fmt_command = "goimports" " automatically format and rewrite imports | |
let g:go_auto_sameids = 1 " highlight matching identifiers | |
"-- vim-go specific configuration (END) | |
"-- coc.nvim specific configuration | |
set hidden | |
set cmdheight=2 | |
set updatetime=100 | |
set shortmess+=c | |
if has("patch-8.1.1564") | |
set signcolumn=number | |
else | |
set signcolumn=yes | |
endif | |
nmap <silent> gr <Plug>(coc-references) | |
nmap <silent> gi <Plug>(coc-implementation) | |
nmap <silent> rn <Plug>(coc-rename) | |
nnoremap <silent> K :call <SID>show_documentation()<CR> | |
function! s:show_documentation() | |
if (index(['vim','help'], &filetype) >= 0) | |
execute 'h '.expand('<cword>') | |
else | |
call CocAction('doHover') | |
endif | |
endfunction | |
"-- coc.nvim specific configuration (END): | |
" nvim-tree | |
nnoremap <leader>e :NvimTreeToggle<CR> | |
let g:nvim_tree_indent_markers = 1 "0 by default, this option shows indent markers when folders are open | |
let g:nvim_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons). | |
let g:nvim_tree_highlight_opened_files = 1 "0 by default, will enable folder and file icon highlight for opened files/directories. | |
let g:nvim_tree_root_folder_modifier = ':~' "This is the default. See :help filename-modifiers for more options | |
let g:nvim_tree_add_trailing = 1 "0 by default, append a trailing slash to folder names | |
let g:nvim_tree_group_empty = 1 " 0 by default, compact folders that only contain a single folder into one node in the file tree | |
let g:nvim_tree_icon_padding = ' ' "one space by default, used for rendering the space between the icon and the filename. Use with caution, it could break rendering if you set an empty string depending on your font. | |
let g:nvim_tree_symlink_arrow = ' >> ' " defaults to ' ➛ '. used as a separator between symlinks' source and target. | |
let g:nvim_tree_respect_buf_cwd = 1 "0 by default, will change cwd of nvim-tree to that of new buffer's when opening nvim-tree. | |
let g:nvim_tree_create_in_closed_folder = 1 "0 by default, When creating files, sets the path of a file when cursor is on a closed folder to the parent folder when 0, and inside the folder when 1. | |
let g:nvim_tree_special_files = { 'README.md': 1, 'Makefile': 1, 'MAKEFILE': 1 } " List of filenames that gets highlighted with NvimTreeSpecialFile | |
let g:nvim_tree_show_icons = { | |
\ 'git': 1, | |
\ 'folders': 1, | |
\ 'files': 1, | |
\ 'folder_arrows': 1, | |
\ } | |
"If 0, do not show the icons for one of 'git' 'folder' and 'files' | |
"1 by default, notice that if 'files' is 1, it will only display | |
"if nvim-web-devicons is installed and on your runtimepath. | |
"if folder is 1, you can also tell folder_arrows 1 to show small arrows next to the folder icons. | |
"but this will not work when you set indent_markers (because of UI conflict) | |
" default will show icon by default if no icon is provided | |
" default shows no icon by default | |
let g:nvim_tree_icons = { | |
\ 'default': "", | |
\ 'symlink': "", | |
\ 'git': { | |
\ 'unstaged': "✗", | |
\ 'staged': "✓", | |
\ 'unmerged': "", | |
\ 'renamed': "➜", | |
\ 'untracked': "★", | |
\ 'deleted': "", | |
\ 'ignored': "◌" | |
\ }, | |
\ 'folder': { | |
\ 'arrow_open': "", | |
\ 'arrow_closed': "", | |
\ 'default': "", | |
\ 'open': "", | |
\ 'empty': "", | |
\ 'empty_open': "", | |
\ 'symlink': "", | |
\ 'symlink_open': "", | |
\ } | |
\ } | |
lua <<EOF | |
require'nvim-tree'.setup() | |
EOF | |
" nvim-tree (END) | |
" telescope | |
nnoremap <leader>ff <cmd>Telescope find_files<cr> | |
nnoremap <leader>fg <cmd>Telescope live_grep<cr> | |
nnoremap <leader>fb <cmd>Telescope buffers<cr> | |
nnoremap <leader>fh <cmd>Telescope help_tags<cr> | |
" telescope (END) | |
" | |
" Monzo settings | |
nnoremap <leader>fs <cmd>Monzo jump_to_component<cr> | |
nnoremap <leader>fd <cmd>Monzo jump_to_downstream<cr> | |
lua <<EOF | |
local lspconfig = require 'lspconfig' | |
local monzo_lsp = require 'monzo.lsp' | |
lspconfig.gopls.setup( | |
monzo_lsp.go_config({on_attach = custom_lsp_attach}) | |
) | |
EOF | |
" ------------------------------------------------------------------------------------------------- | |
" coc.nvim default settings | |
" ------------------------------------------------------------------------------------------------- | |
" if hidden is not set, TextEdit might fail. | |
set hidden | |
" Better display for messages | |
set cmdheight=2 | |
" don't give |ins-completion-menu| messages. | |
set shortmess+=c | |
" always show signcolumns | |
set signcolumn=yes | |
" " Use tab for trigger completion with characters ahead and navigate. | |
" " Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin. | |
" inoremap <silent><expr> <TAB> | |
" \ pumvisible() ? "\<C-n>" : | |
" \ <SID>check_back_space() ? "\<TAB>" : | |
" \ coc#refresh() | |
" inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" | |
" function! s:check_back_space() abort | |
" let col = col('.') - 1 | |
" return !col || getline('.')[col - 1] =~# '\s' | |
" endfunction | |
" Use <c-space> to trigger completion. | |
inoremap <silent><expr> <c-space> coc#refresh() | |
" Use `[c` and `]c` to navigate diagnostics | |
nmap <silent> [c <Plug>(coc-diagnostic-prev) | |
nmap <silent> ]c <Plug>(coc-diagnostic-next) | |
" Remap keys for gotos | |
nmap <silent> gd <Plug>(coc-definition) | |
nmap <silent> gy <Plug>(coc-type-definition) | |
nmap <silent> gi <Plug>(coc-implementation) | |
nmap <silent> gr <Plug>(coc-references) | |
" Use U to show documentation in preview window | |
nnoremap <silent> U :call <SID>show_documentation()<CR> | |
function! s:show_documentation() | |
if (index(['vim','help'], &filetype) >= 0) | |
execute 'h '.expand('<cword>') | |
elseif (coc#rpc#ready()) | |
call CocActionAsync('doHover') | |
else | |
execute '!' . &keywordprg . " " . expand('<cword>') | |
endif | |
endfunction | |
" Remap for rename current word | |
nmap <leader>rn <Plug>(coc-rename) | |
" Remap for format selected region | |
vmap <leader>f <Plug>(coc-format-selected) | |
nmap <leader>f <Plug>(coc-format-selected) | |
" Show all diagnostics | |
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr> | |
" Manage extensions | |
"nnoremap <silent> <space>e :<C-u>CocList extensions<cr> | |
" Show commands | |
nnoremap <silent> <space>c :<C-u>CocList commands<cr> | |
" Find symbol of current document | |
nnoremap <silent> <space>o :<C-u>CocList outline<cr> | |
" Search workspace symbols | |
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr> | |
" Do default action for next item. | |
nnoremap <silent> <space>j :<C-u>CocNext<CR> | |
" Do default action for previous item. | |
nnoremap <silent> <space>k :<C-u>CocPrev<CR> | |
" Resume latest coc list | |
nnoremap <silent> <space>p :<C-u>CocListResume<CR> | |
nnoremap <silent> <C-l> :<C-u>coc-snippets-expand<cr> | |
inoremap <silent><expr> <TAB> | |
\ pumvisible() ? coc#_select_confirm() : | |
\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" : | |
\ <SID>check_back_space() ? "\<TAB>" : | |
\ coc#refresh() | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~# '\s' | |
endfunction | |
let g:coc_snippet_next = '<tab>' | |
" ------------------------------------------------------------------------------------------------- | |
" coc.nvim default settings (END) | |
" ------------------------------------------------------------------------------------------------- | |
" to make sure tabs are 4 spaces in go files | |
set ts=4 | |
" disable vim-go :GoDef short cut (gd) | |
" this is handled by LanguageClient [LC] | |
let g:go_def_mapping_enabled = 0 | |
" go syntax highlighting | |
let g:go_highlight_types = 1 | |
let g:go_highlight_fields = 1 | |
let g:go_highlight_functions = 1 | |
let g:go_highlight_function_calls = 1 | |
let g:go_highlight_extra_types = 1 | |
let g:go_highlight_generate_tags = 1 | |
let g:go_gopls_enabled = 0 " disable vim-go lsp (we're using coc instead) | |
" Enable to copy to clipboard for operations like yank, delete, change and put | |
" http://stackoverflow.com/questions/20186975/vim-mac-how-to-copy-to-clipboard-without-pbcopy | |
if has('unnamedplus') | |
set clipboard^=unnamed | |
set clipboard^=unnamedplus | |
endif | |
" This enables us to undo files even if you exit Vim. | |
if has('persistent_undo') | |
set undofile | |
set undodir=~/.config/vim/tmp/undo// | |
endif | |
" Colorscheme | |
syntax enable | |
set t_Co=256 | |
let g:rehash256 = 1 | |
let g:molokai_original = 1 | |
colorscheme gruvbox |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment