From 07ab3a77b44944a1ac234fbd717391f36370416e Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Tue, 17 Oct 2017 18:12:57 -0600 Subject: initial public commit --- nvim/default.nix | 94 ++++++++++++++++++++++++++++++ nvim/init.vim | 170 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 264 insertions(+) create mode 100644 nvim/default.nix create mode 100644 nvim/init.vim (limited to 'nvim') diff --git a/nvim/default.nix b/nvim/default.nix new file mode 100644 index 0000000..d6d4a94 --- /dev/null +++ b/nvim/default.nix @@ -0,0 +1,94 @@ +{ + + pkgs ? (import ../pkgs.nix) {}, + +}: rec { + + goimports = pkgs.buildGoModule rec { + pname = "goimports"; + version = "v0.1.7"; + src = builtins.fetchGit { + url = "https://go.googlesource.com/tools"; + rev = "0df0ca0f43117120bd7cc900ebf765f9b799438a"; + }; + vendorSha256 = "1vs4vbl3kh8lbqrm4yqqn27ammlqj7jdbi0ca9s4fkja2sk45ibi"; + subPackages = [ "cmd/goimports" ]; + }; + + # the gocode-gomod which comes with nixpkgs places the binary at + # gocode-gomod, we gotta rename it + gocode = pkgs.stdenv.mkDerivation { + name = "gocode"; + src = pkgs.gocode-gomod; + builder = builtins.toFile "builder.sh" '' + source $stdenv/setup + mkdir -p "$out"/bin/ + cp "$src"/bin/gocode-gomod "$out"/bin/gocode + ''; + }; + + env = pkgs.buildEnv { + name = "nvim-env"; + paths = [ + pkgs.vimPlugins.vim-plug + pkgs.vimPlugins.deoplete-nvim + pkgs.vimPlugins.deoplete-go + pkgs.vimPlugins.nerdtree + pkgs.vimPlugins.nerdtree-git-plugin + pkgs.vimPlugins.vim-gitgutter + pkgs.vimPlugins.neomake + pkgs.vimPlugins.papercolor-theme + pkgs.vimPlugins.vim-go + pkgs.vimPlugins.vim-nix + + pkgs.golangci-lint + pkgs.gopls + gocode + goimports + ]; + }; + + envPlugins = "${env}/share/vim-plugins"; + + init = pkgs.writeText "nvim-init" '' + source ${envPlugins}/vim-plug/plug.vim + + call plug#begin('${envPlugins}') + Plug '${envPlugins}/deoplete-nvim' + Plug '${envPlugins}/deoplete-go', { 'for': 'go' } + Plug '${envPlugins}/nerdtree', { 'on': 'NERDTreeToggle' } + Plug '${envPlugins}/nerdtree-git-plugin' + Plug '${envPlugins}/vim-gitgutter' + Plug '${envPlugins}/neomake' + Plug '${envPlugins}/papercolor-theme' + Plug '${envPlugins}/vim-go', { 'for': 'go' } + Plug '${envPlugins}/vim-nix', { 'for': 'nix' } + call plug#end() + + source ${./init.vim} + ''; + + nvimRaw = pkgs.writeScriptBin "nvim" '' + #!${pkgs.bash}/bin/bash + export PATH=${env}/bin:$PATH + exec ${pkgs.neovim}/bin/nvim -u ${init} "$@" + ''; + + rplugin = pkgs.stdenv.mkDerivation { + name = "nvim-rplugin"; + buildInputs = [ pkgs.git nvimRaw ]; + builder = builtins.toFile "builder.sh" '' + source $stdenv/setup + mkdir -p "$out"/ + export NVIM_RPLUGIN_MANIFEST="$out"/rplugin.vim + nvim -c ':UpdateRemotePlugins' -c ':exit' >/dev/null + ''; + }; + + nvim = pkgs.writeScriptBin "nvim" '' + #!${pkgs.bash}/bin/bash + export NVIM_RPLUGIN_MANIFEST=${rplugin}/rplugin.vim + exec ${nvimRaw}/bin/nvim "$@" + ''; + +} diff --git a/nvim/init.vim b/nvim/init.vim new file mode 100644 index 0000000..630b90d --- /dev/null +++ b/nvim/init.vim @@ -0,0 +1,170 @@ +" PaperColor ############################################################### + +set background=light +colorscheme PaperColor + +" Deoplete ################################################################# +let g:deoplete#enable_at_startup = 1 +" use tab to cycle +inoremap pumvisible() ? "\" : "\" +" close preview when leaving insert +autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif + +" NERDTree ################################################################# +let NERDTreeMouseMode=3 +let NERDTreeMinimalUI=1 +let NERDTreeAutoDeleteBuffer=1 +let NERDTreeHighlightCursorline=1 +let NERDTreeShowHidden=1 +let g:NERDTreeIndicatorMapCustom = { + \ "Modified" : "Δ", + \ "Staged" : "✚", + \ "Untracked" : "✭", + \ "Renamed" : "➜", + \ "Unmerged" : "☢", + \ "Deleted" : "-", + \ "Dirty" : "Δ", + \ "Clean" : "", + \ "Unknown" : "" + \ } + +map :NERDTreeToggle +" always enter term buffer in insert mode +autocmd BufEnter * if &buftype == 'terminal' | :startinsert | endif + +" vim-go ################################################################### +" +"use goimports for formatting instead of gofmt +let g:go_fmt_command = "goimports" + +" neomake ################################################################## +autocmd! BufWritePost * Neomake +"let g:neomake_verbose=3 +"let g:neomake_logfile='/tmp/neomake.log' + +" the sidebar sign placement wasn't playing nice with gitgutter, so use the +" location list instead. But location list is kinda dumb cause it pops open +" multiple times and at weird times, sooo.... fuck it +"let g:neomake_open_list=2 +let g:neomake_open_list=0 +let g:neomake_place_signs=0 + +let g:neomake_go_enabled_makers = ['go', 'golangcilint'] +let g:neomake_go_golangcilint_maker = { + \ 'exe': 'golangci-lint', + \ 'args': [ + \ 'run', + \ '--no-config', + \ '--out-format=line-number', + \ '--print-issued-lines=false', + \ '-E=durationcheck', + \ '-E=errorlint', + \ '-E=exportloopref', + \ '-E=forbidigo', + \ '-E=gochecknoinits', + \ '-E=godot', + \ '-E=goimports', + \ '-E=misspell', + \ '-E=revive', + \ '-E=unconvert', + \ '-E=unparam', + \ '.' + \ ], + \ 'output_stream': 'stdout', + \ 'append_file': 0, + \ 'cwd': '%:h', + \ 'errorformat': + \ '%f:%l:%c: %m,' . + \ '%f:%l: %m' + \ } + +let g:neomake_markdown_enabled_makers = ['misspell'] +let g:neomake_markdown_misspell_maker = { + \ 'errorformat': '%f:%l:%c:%m', + \ } + +" mine ##################################################################### + +"Makes current line/column highlighted, and set text width +set tw=80 +set colorcolumn=+1 +"autocmd bufenter * set cursorline cursorcolumn colorcolumn=+1 +"autocmd bufleave * set nocursorline nocursorcolumn colorcolumn=0 +hi ColorColumn ctermfg=none ctermbg=grey cterm=none +"hi CursorLine ctermfg=none ctermbg=lightgrey cterm=none +"hi CursorColumn ctermfg=none ctermbg=lightgrey cterm=none + +"Buffers scroll a bit so cursor doens't go all the way to the bottom before +"scroll begins +set scrolloff=3 + +"Makes all .swp files go to /tmp instead of . CAUSE FUCK DA POLICE +set backupdir=/tmp +set directory=/tmp + +"Better indenting +set autoindent +set expandtab +set tabstop=4 +set shiftwidth=4 + +"Show eol and tabs +set list +set listchars=trail:░,tab:►\ ,extends:>,precedes:< + +"Don't highlight search matches, don't jump while mid-search +set noincsearch +set nohlsearch + +"We want certain types to only have 2 space for tabs +au FileType clojure setlocal tabstop=2 shiftwidth=2 +au FileType ruby setlocal tabstop=2 shiftwidth=2 +au FileType yaml setlocal tabstop=2 shiftwidth=2 +au FileType html setlocal tabstop=2 shiftwidth=2 +au FileType proto setlocal tabstop=2 shiftwidth=2 +au FileType javascript setlocal tabstop=2 shiftwidth=2 + +"We want certain types to use tabs instead of spaces +au FileType go setlocal nolist noexpandtab +au FileType make setlocal nolist noexpandtab + +"terminal shortcuts +tnoremap \ +tnoremap +"tab shortcuts for terminal mode have terminal escape code preceding them +tnoremap tn :tabe term://zsh +tnoremap tN :tabe +tnoremap ts :vs term://zsh +tnoremap tS :vnew +tnoremap ti :sp term://zsh +tnoremap tI :new +tnoremap th gT +tnoremap tH :-tabmove +tnoremap tl gt +tnoremap tL :+tabmove +tnoremap tx :tabclose + +"tab shortcuts +noremap tn :tabe term://zsh +noremap tN :tabe +noremap ts :vs term://zsh +noremap tS :vnew +noremap ti :sp term://zsh +noremap tI :new +noremap th gT +noremap tH :-tabmove +noremap tl gt +noremap tL :+tabmove +noremap tx :tabclose + +" yank/paste into/from clipboard +set clipboard+=unnamedplus + +"Clojure specific mappings +" Eval outerform +au FileType clojure nmap cpP :Eval +" Eval full page +au FileType clojure nmap cpR :%Eval + +" Disable Ex mode! +nnoremap Q -- cgit v1.2.3