Last active
April 21, 2023 15:53
-
-
Save diegomarangoni/e73f698b71e0c46df5a1940d80cf4109 to your computer and use it in GitHub Desktop.
Golang Vim/Neovim
This file contains 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
"~/.vimrc | |
"***************************************************************************** | |
"" install vim-plug | |
"***************************************************************************** | |
let vimplug_exists=expand('~/.vim/autoload/plug.vim') | |
let g:vim_bootstrap_langs='go,html,javascript,typescript' | |
let g:vim_bootstrap_editor='vim' | |
if !filereadable(vimplug_exists) | |
if !executable("curl") | |
echoerr "You have to install curl or first install vim-plug yourself!" | |
execute "q!" | |
endif | |
echo "Installing Vim-Plug..." | |
echo "" | |
silent exec "!\curl -fLo " . vimplug_exists . " --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" | |
let g:not_finish_vimplug='yes' | |
autocmd VimEnter * PlugInstall | |
endif | |
call plug#begin(expand('~/.vim/plugged')) | |
Plug 'airblade/vim-gitgutter' | |
Plug 'cespare/vim-toml' | |
Plug 'diegomarangoni/vim-spacemacs' | |
Plug 'dracula/vim', { 'as': 'dracula' } | |
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } | |
Plug 'hashivim/vim-terraform' | |
Plug 'jiangmiao/auto-pairs' | |
Plug 'junegunn/fzf', { 'do': './install --bin' } | |
Plug 'junegunn/fzf.vim' | |
Plug 'preservim/nerdtree' | |
Plug 'tpope/vim-commentary' | |
Plug 'tpope/vim-fugitive' | |
Plug 'tpope/vim-sensible' | |
Plug 'tpope/vim-surround' | |
Plug 'vim-airline/vim-airline' | |
Plug 'vim-syntastic/syntastic' | |
Plug 'ycm-core/YouCompleteMe' | |
call plug#end() | |
"***************************************************************************** | |
"" config | |
"***************************************************************************** | |
" set | |
set nocompatible " disable vi compatibility | |
set number " show current line number | |
set relativenumber " show relative line numbers | |
set hidden " allow change buffer without saving | |
set termguicolors " enable true colors support | |
set cursorline " highlight cursor line | |
set hlsearch " highlight search pattern | |
set belloff=all " disable audio bell | |
set clipboard=unnamed " to make clipboard works | |
set completeopt=menuone " show completion in a popup menu | |
set directory=~/.vim/swap/ " path to store swap files | |
set rtp+=/usr/local/opt/fzf " add fzf to runtime path | |
if has("nvim") | |
set inccommand=nosplit " command live preview | |
endif | |
" creates swap files directory if necessary | |
if !isdirectory(expand(&directory)) | |
call mkdir(expand(&directory), "p") | |
endif | |
" cursor shape on insert mode | |
let &t_SI="\<Esc>]1337;CursorShape=1\x7" | |
let &t_EI="\<Esc>]1337;CursorShape=0\x7" | |
" make italic works | |
let &t_ZH="\e[3m" | |
let &t_ZR="\e[23m" | |
" leader key | |
let mapleader=',' | |
" nerdtree | |
let NERDTreeMinimalUI=1 | |
let NERDTreeCascadeSingleChildDir=0 | |
"***************************************************************************** | |
"" syntastic | |
"***************************************************************************** | |
set statusline+=%#warningmsg# | |
set statusline+=%{SyntasticStatuslineFlag()} | |
set statusline+=%* | |
let g:syntastic_always_populate_loc_list = 1 | |
let g:syntastic_auto_loc_list = 1 | |
let g:syntastic_check_on_open = 1 | |
let g:syntastic_check_on_wq = 0 | |
"***************************************************************************** | |
"" golang | |
"***************************************************************************** | |
" set tab width of 4 spaces for go | |
autocmd! BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 | |
let g:go_fmt_command="goimports" | |
let g:go_rename_command="gopls" | |
" improves Go syntax highlighting | |
let g:go_highlight_operators=1 | |
let g:go_highlight_functions=1 | |
let g:go_highlight_function_parameters=1 | |
let g:go_highlight_function_calls=1 | |
let g:go_highlight_types=1 | |
let g:go_highlight_fields=1 | |
"***************************************************************************** | |
"" theming | |
"***************************************************************************** | |
try | |
colorscheme dracula | |
catch /^Vim\%((\a\+)\)\=:E185/ | |
colorscheme default | |
endtry | |
"***************************************************************************** | |
"" mapping | |
"***************************************************************************** | |
" use visual selected text as pattern when `*` | |
vmap * y:let @/ = escape(@", '/\*.')<CR>nN | |
" prevent cursor movement when `*` | |
nmap * *N | |
" add autocomplete window navigation with `TAB` and `C-k,j` | |
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>" | |
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>" | |
inoremap <expr> <C-j> pumvisible() ? "\<C-n>" : "\<Tab>" | |
inoremap <expr> <C-k> pumvisible() ? "\<C-p>" : "\<S-Tab>" | |
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<cr>" | |
" smart way to move between windows | |
map <C-j> <C-W>j | |
map <C-k> <C-W>k | |
map <C-h> <C-W>h | |
map <C-l> <C-W>l | |
" alias leader key to space bar | |
map <Space> <leader> |
This file contains 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
"~/.config/nvim/init.vim | |
set runtimepath^=~/.vim runtimepath+=~/.vim/after | |
let &packpath = &runtimepath | |
source ~/.vimrc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment