Skip to content

Instantly share code, notes, and snippets.

@Velrok
Last active November 23, 2020 21:31
Show Gist options
  • Save Velrok/bbcd666197244dfc51ef97fdc230ba0e to your computer and use it in GitHub Desktop.
Save Velrok/bbcd666197244dfc51ef97fdc230ba0e to your computer and use it in GitHub Desktop.
───────┬────────────────────────────────────────────────────────────────────────
│ File: /Users/waldemar/.config/nvim/init.vim
───────┼────────────────────────────────────────────────────────────────────────
1 │ call plug#begin()
2 │ " Global:
3 │ Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
4 │ " Plug 'kien/ctrlp.vim'
5 │ Plug 'tpope/vim-sensible'
6 │ Plug 'rking/ag.vim'
7 │ Plug 'scrooloose/nerdtree'
8 │ Plug 'Chiel92/vim-autoformat'
9 │ Plug 'ervandew/supertab'
10 │ Plug 'godlygeek/tabular'
11 │ Plug 'majutsushi/tagbar' " brew install ctags than :TagbarToggle
12 │ Plug 'w0rp/ale' " async linter
13 │ Plug 'itchyny/lightline.vim' " quick and simple status bar
14 │ Plug 'maximbaz/lightline-ale' "
15 │
16 │ " Git stuff
17 │ Plug 'itchyny/vim-gitbranch'
18 │ Plug 'vimwiki/vimwiki'
19 │
20 │ Plug 'skywind3000/asyncrun.vim'
21 │
22 │ Plug 'tpope/vim-dispatch'
23 │ Plug 'radenling/vim-dispatch-neovim' " requires 'tpope/vim-dispatch'
24 │
25 │ Plug 'tpope/vim-repeat'
26 │ Plug 'kana/vim-textobj-user'
27 │ Plug 'tpope/vim-surround'
28 │ Plug 'chr4/nginx.vim'
29 │ Plug 'ekalinin/Dockerfile.vim'
30 │ Plug 'roman/golden-ratio'
31 │
32 │ " Plug 'vim-scripts/Sunset'
33 │
34 │ " Dark powered asynchronous completion framework for neovim/Vim8
35 │ " Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
36 │ " Plug 'Shougo/deoplete-lsp' " keeps failing with lua errors on insert
37 │ " Plug 'neovim/nvim-lsp' " keeps failing with lua errors on insert
38 │
39 │ Plug 'ncm2/float-preview.nvim'
40 │
41 │ Plug 'godlygeek/tabular' " tabular plugin is used to format tables
42 │ Plug 'sheerun/vim-polyglot' " installs syntax and indentation support for many languages
43 │
44 │ " Note: Gave this a spint but it needs a lot more investigation.
45 │ " powerfull code completion and semantics
46 │ " will need language servers or plugins per lang
47 │ " NEEDS Node: :termtab curl -sL install-node.now.sh/lts | bash
48 │ " :tabedit term://curl -sL install-node.now.sh/lts | bash
49 │ " Plug 'neoclide/coc.nvim', {'branch': 'release'}
50 │
51 │ " JSON:
52 │ " front matter highlight plugin
53 │ Plug 'elzr/vim-json'
54 │
55 │ " Ruby:
56 │ Plug 'vim-scripts/ruby-matchit'
57 │ Plug 'nelstrom/vim-textobj-rubyblock'
58 │
59 │ " Markdown:
60 │ Plug 'plasticboy/vim-markdown'
61 │
62 │ " SQL:
63 │ Plug 'tpope/vim-dadbod'
64 │ Plug 'mattn/vim-sqlfmt'
65 │
66 │ " Clojure:
67 │ Plug 'guns/vim-clojure-static'
68 │ " Plug 'clojure-vim/vim-jack-in'
69 │ Plug 'Olical/conjure', {'tag': 'v4.9.0'}
70 │ Plug 'luochen1990/rainbow'
71 │ Plug 'guns/vim-sexp'
72 │ Plug 'tpope/vim-sexp-mappings-for-regular-people'
73 │
74 │ " Html:
75 │ Plug 'alvan/vim-closetag'
76 │
77 │ " Rust:
78 │ Plug 'rust-lang/rust.vim'
79 │
80 │ " Color_themes:
81 │ Plug 'cormacrelf/vim-colors-github'
82 │ Plug 'frankier/neovim-colors-solarized-truecolor-only'
83 │ Plug 'NLKNguyen/papercolor-theme'
84 │
85 │ call plug#end()
86 │
87 │ " Options:
88 │
89 │ set secure " disable unsafe commands in local .vimrc files
90 │
91 │ set scrolloff=5 " allways show at least 5 lines
92 │ set wildmode=longest,list " autocomplete mode
93 │
94 │ set nowrap " don't wrap lines
95 │ set backspace=indent,eol,start " allow backspacing over everything in insert mode
96 │ set autoindent " always set autoindenting on
97 │ set copyindent " copy the previous indentation on autoindenting
98 │ set number " always show line numbers
99 │ set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
100 │ set showmatch " set show matching parenthesis
101 │ set ignorecase " ignore case when searching
102 │ set smartcase " ignore case if search pattern is all lowercase, case-sensitive otherwise
103 │ set expandtab
104 │ set tabstop=2 " a tab is two spaces
105 │ set shiftwidth=2 " number of spaces to use for autoindenting
106 │ set smarttab " insert tabs on the start of a line according to shiftwidth, not tabstop
107 │ set hlsearch " highlight search terms
108 │ set incsearch " show search matches as you type
109 │ " dont clutter
110 │ set nobackup
111 │ set noswapfile
112 │ " disable mac beeping
113 │ set vb
114 │ set laststatus=2
115 │ set statusline+=%F
116 │ set encoding=utf-8
117 │ set cursorline
118 │ set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.class,*.jar,*/target/*
119 │
120 │ "Open new split panes to right and bottom, which feels more natural than Vim’s default:
121 │ set splitbelow
122 │ set splitright
123 │
124 │ set relativenumber
125 │ set autoread " auto reload file changes
126 │ set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<,space:∙
127 │
128 │ set completeopt-=preview
129 │ set nofoldenable " disable folding
130 │ " set clipboard=unnamed " yank and past use the OS clipboard
131 │ set clipboard=unnamedplus " better yank and past use the OS clipboard https://stackoverflow.com/questions/2861627/paste-in-insert-mode
132 │
133 │ " Clojure_files:
134 │ autocmd BufNewFile,BufRead *.cljx set filetype=clojure
135 │ autocmd BufNewFile,BufRead *.cljc set filetype=clojure
136 │ autocmd BufNewFile,BufRead *.pxi set filetype=clojure
137 │ autocmd BufNewFile,BufRead *.joker set filetype=clojure
138 │
139 │ " SQL_files:
140 │ " set sql syntax for hql files
141 │ autocmd BufNewFile,BufRead *.hql set filetype=sql
142 │
143 │ " Python_files:
144 │ " puppet: use pyton highlighting for pupet pp files
145 │ autocmd BufNewFile,BufRead *.pp set filetype=python
146 │
147 │ syntax on
148 │
149 │ """ Python3 VirtualEnv
150 │ " PYTHON VIRTUALENVS *python-virtualenv*
151 │ " If you plan to use per-project virtualenvs often, you should assign one
152 │ " virtualenv for Neovim and hard-code the interpreter path via
153 │ " |g:python3_host_prog| (or |g:python_host_prog|) so that the "pynvim" package
154 │ " is not required for each virtualenv.
155 │ "
156 │ " Example using pyenv:
157 │ " pyenv install 3.4.4
158 │ " pyenv virtualenv 3.4.4 py3nvim
159 │ " pyenv activate py3nvim
160 │ " pip install pynvim
161 │ " pyenv which python # Note the path
162 │ " The last command reports the interpreter path, add it to your init.vim:
163 │ " let g:python3_host_prog = '/path/to/py3nvim/bin/python'
164 │ "
165 │ " See also: https://github.com/zchee/deoplete-jedi/wiki/Setting-up-Python-for-Neovimk
166 │ "
167 │ let g:python3_host_prog = "/usr/local/bin/python3"
168 │
169 │ command! Json :%!jq -M '.'
170 │
171 │ " enable matchit for text objects
172 │ runtime macros/matchit.vim
173 │
174 │ " The Silver Searcher
175 │ if executable('ag')
176 │ " Use ag over grep
177 │ set grepprg=ag\ --nogroup\ --nocolor
178 │ endif
179 │
180 │ " turn off syntax highlighting for large files
181 │ autocmd BufWinEnter * if line2byte(line("$") + 1) > 1000000 | syntax clear | endif
182 │
183 │ augroup highlight_yank
184 │ autocmd!
185 │ au TextYankPost * silent! lua vim.highlight.on_yank{higroup="IncSearch", timeout=200}
186 │ augroup END
187 │
188 │ "-------------- keybindings ----------------------------
189 │
190 │ " Define Leader key
191 │ let mapleader = " "
192 │ let maplocalleader = "§"
193 │
194 │ nnoremap <S-Right> :tabnext<CR>
195 │ nnoremap <S-Left> :tabprevious<CR>
196 │ nnoremap <Leader>t :tabnew<CR>
197 │
198 │ " switch between panes as one would navigate text
199 │ map <C-j> <C-W>j
200 │ map <C-k> <C-W>k
201 │ map <C-h> <C-W>h
202 │ map <C-l> <C-W>l
203 │
204 │ " writting
205 │ nnoremap <Leader>w :w<CR>
206 │ " autocmd InsertLeave :w<CR> " maybe a bit too agressive
207 │
208 │ " quick exit
209 │ nnoremap <Leader>q :x<CR>
210 │
211 │ " replace word under cursor
212 │ nnoremap <Leader>s :%s/\<<C-r><C-w>\>/<C-r><C-w>/gc<Left><Left><Left>
213 │
214 │ " remove tailing spaces
215 │ command! RemoveTailingSpaces :%s/\s\+$//e
216 │ nnoremap <silent> <Leader>r :RemoveTailingSpaces<CR>
217 │
218 │ nnoremap <silent> <Leader>b :TagbarToggle<CR>
219 │ nnoremap <silent> <Leader>n :NERDTreeToggle<CR>
220 │
221 │ " allow the . to execute once for each line of a visual selection
222 │ vnoremap . :normal .<CR>
223 │
224 │ " TODO list editing
225 │ " create a new todo item in a new line
226 │ nnoremap <C-t> A<cr>- [ ]
227 │
228 │ " mark a tas as completed
229 │ nnoremap <C-c> 0t]rx
230 │ " mark a tas as NOT completed
231 │ nnoremap <C-n> 0t]r
232 │
233 │ let g:deoplete#enable_at_startup = 1
234 │
235 │ " move line up
236 │ nmap <C-k> :move -2<CR>
237 │ " move line down
238 │ nmap <C-j> :move +1<CR>
239 │
240 │ " --------------------------- color -----------------------------
241 │
242 │ " Color_scheme:
243 │ set background=dark
244 │ "colorscheme solarized
245 │ colorscheme PaperColor
246 │
247 │ " exit Terminal mode with ESC
248 │ :tnoremap <Esc> <C-\><C-n>
249 │
250 │ " ctrlp && fzf
251 │ nmap <C-P> :FZF<CR>
252 │
253 │ command! EditNvimRc :e ~/.config/nvim/init.vim
254 │
255 │ " Alacrity transparent BG fix
256 │ hi! Normal ctermbg=NONE guibg=NONE
257 │ hi! NonText ctermbg=NONE guibg=NONE guifg=NONE ctermfg=NONE
258 │
───────┴────────────────────────────────────────────────────────────────────────
───────┬────────────────────────────────────────────────────────────────────────
│ File: /Users/waldemar/.config/nvim/after/ftplugin/bash.vim
───────┼────────────────────────────────────────────────────────────────────────
1 │ noremap ; :!bash %<CR>
───────┴────────────────────────────────────────────────────────────────────────
───────┬────────────────────────────────────────────────────────────────────────
│ File: /Users/waldemar/.config/nvim/after/ftplugin/clojure.vim
───────┼────────────────────────────────────────────────────────────────────────
1 │ let tlist_clojure_settings = 'lisp;f:function'
2 │
3 │ " sexp shortcuts
4 │ nmap <D-l> >)
5 │ nmap <D-k> <)
6 │ nmap <D-j> >(
7 │ nmap <D-h> <(
8 │
9 │ let g:rainbow_active = 1 "set to 0 if you want to enable it later via :RainbowToggle
10 │
11 │ " clojure repl
12 │ " configure Conjure BEGIN
13 │ let g:conjure#log#hud#width='0.75'
14 │ let g:conjure#log#hud#height='0.9'
15 │ :command! ConjureReconnect :let @x = system('cat ./.nrepl-port') | execute "ConjureConnect " . @x
16 │ " configure Conjure END
17 │
18 │ " Tabular Patterns
19 │ command! AlignCljRequired Tabularize/ :.*/l0
20 │
21 │ " clojure repl
22 │ command! ComponentRestartSystem :Eval (user/reset)
23 │ nnoremap <M-r> :ComponentRestartSystem<CR>
24 │
25 │ " cljs node repl
26 │ command! CljsNodeRepl :Piggieback (cljs.repl.node/repl-env)
27 │
28 │ command! PrintLastException :Eval (clojure.stacktrace/print-cause-trace *e)
29 │ nnoremap <M-p> :PrintLastException<CR>
30 │
31 │ nmap , <localleader>ee
32 │ nmap ; <localleader>eb
33 │
34 │
35 │ " clojure Conjure config
36 │ " https://oli.me.uk/getting-started-with-clojure-neovim-and-conjure-in-minutes/
37 │
38 │ let g:ale_linters = {
39 │ \ 'clojure': ['joker', 'clj-kondo']
40 │ \}
41 │
42 │ command! ClojureRepl :tabedit term://lein repl
43 │
───────┴────────────────────────────────────────────────────────────────────────
───────┬────────────────────────────────────────────────────────────────────────
│ File: /Users/waldemar/.config/nvim/after/ftplugin/markdown.vim
───────┼────────────────────────────────────────────────────────────────────────
1 │ " Source: https://jdhao.github.io/2019/01/15/markdown_edit_preview_nvim/
2 │
3 │ " wrap lines in tex and md files
4 │ set textwidth=80
5 │ set wrap
6 │
7 │ setlocal spell spelllang=en_gb
8 │
9 │ " disable header folding
10 │ let g:vim_markdown_folding_disabled = 1
11 │
12 │ " do not use conceal feature, the implementation is not so good
13 │ let g:vim_markdown_conceal = 0
14 │
15 │ " disable math tex conceal feature
16 │ let g:tex_conceal = ""
17 │ let g:vim_markdown_math = 1
18 │
19 │ " support front matter of various format
20 │ let g:vim_markdown_frontmatter = 1 " for YAML format
21 │ let g:vim_markdown_toml_frontmatter = 1 " for TOML format
22 │ let g:vim_markdown_json_frontmatter = 1 " for JSON format
23 │
24 │ " do not close the preview tab when switching to other buffers
25 │ let g:mkdp_auto_close = 0
26 │
27 │ nnoremap <M-m>:MarkdownPreview<CR>
28 │
29 │ if exists("*GonvimGridFont")
30 │ GonvimGridFont "Courier New:h18"
31 │ endif
───────┴────────────────────────────────────────────────────────────────────────
───────┬────────────────────────────────────────────────────────────────────────
│ File: /Users/waldemar/.config/nvim/after/ftplugin/python.vim
───────┼────────────────────────────────────────────────────────────────────────
1 │ " adhere to python identation standards
2 │ set tabstop=4
3 │ set shiftwidth=4
4 │
5 │ " quick execute for python
6 │ autocmd FileType python nmap ; :!python3 %<CR>
───────┴────────────────────────────────────────────────────────────────────────
───────┬────────────────────────────────────────────────────────────────────────
│ File: /Users/waldemar/.config/nvim/after/ftplugin/ruby.vim
───────┼────────────────────────────────────────────────────────────────────────
1 │ " autoclose for ruby
2 │ " au FileType ruby let b:delimitMate_matchpairs = "(:),[:],{:},|:|"
3 │ let b:delimitMate_quotes = "\" |"
4 │
5 │ " use old regex engine for ruby, because the new one is slow for ruby
6 │ set re=1
───────┴────────────────────────────────────────────────────────────────────────
───────┬────────────────────────────────────────────────────────────────────────
│ File: /Users/waldemar/.config/nvim/after/ftplugin/rust.vim
───────┼────────────────────────────────────────────────────────────────────────
1 │ " setup rust_analyzer LSP (IDE features)
2 │ " lua require'nvim_lsp'.rust_analyzer.setup{}
3 │ "
4 │ " " Use LSP omni-completion in Rust files
5 │ " autocmd Filetype rust setlocal omnifunc=v:lua.vim.lsp.omnifunc
6 │ "
7 │ " " Enable deoplete autocompletion in Rust files
8 │ " let g:deoplete#enable_at_startup = 1
9 │ "
10 │ "
11 │ " " customise deoplete " maximum candidate window length
12 │ " call deoplete#custom#source('_', 'max_menu_width', 80)
13 │ "
14 │ "
15 │ " " Press Tab to scroll _down_ a list of auto-completions
16 │ " let g:SuperTabDefaultCompletionType = "<c-n>"
17 │ "
18 │ " " rustfmt on write using autoformat
19 │ " autocmd BufWrite * :Autoformat
20 │ "
21 │ " "TODO: clippy on write
22 │ " autocmd BufWrite * :Autoformat
23 │ "
24 │ " nnoremap <leader>c :!cargo clippy
25 │
26 │ let g:rustfmt_autosave = 1
27 │
───────┴────────────────────────────────────────────────────────────────────────
───────┬────────────────────────────────────────────────────────────────────────
│ File: /Users/waldemar/.config/nvim/after/ftplugin/sql.vim
───────┼────────────────────────────────────────────────────────────────────────
1 │ " allow execution of sql paragraph using tpope/vim-db
2 │ nmap <buffer>; vip:DB<CR>
3 │ nmap <buffer> == :SQLFmt<CR>
───────┴────────────────────────────────────────────────────────────────────────
───────┬────────────────────────────────────────────────────────────────────────
│ File: /Users/waldemar/.config/nvim/after/ftplugin/vimwiki.vim
───────┼────────────────────────────────────────────────────────────────────────
1 │ echo "loaded vimwiki"
2 │ " requires Plug 'skywind3000/asyncrun.vim'
3 │ autocmd vimwiki BufWritePost *.md AsyncRun cd $HOME/vimwiki && git pull && git add . && git ci -am 'autoupdate' && git push
4 │
5 │ if exists("*GonvimMarkdown")
6 │ autocmd vimwiki BufReadPost :GonvimMarkdown
7 │ endif
8 │
9 │ if exists("*GonvimGridFont")
10 │ GonvimGridFont "Courier New:h18"
11 │ endif
───────┴────────────────────────────────────────────────────────────────────────
───────┬────────────────────────────────────────────────────────────────────────
│ File: /Users/waldemar/.config/nvim/plugin/config/golden_ratio.vim
───────┼────────────────────────────────────────────────────────────────────────
1 │ " golden ratio config
2 │ let g:golden_ratio_exclude_nonmodifiable = 1
───────┴────────────────────────────────────────────────────────────────────────
───────┬────────────────────────────────────────────────────────────────────────
│ File: /Users/waldemar/.config/nvim/plugin/config/lightline.vim
───────┼────────────────────────────────────────────────────────────────────────
1 │ set laststatus=2
2 │
3 │ " By the way, -- INSERT -- is unnecessary anymore because the mode information is displayed in the statusline.
4 │ set noshowmode
5 │
6 │ "let g:lightline = {
7 │ " \ 'colorscheme': 'solarized',
8 │ " \ }
9 │
10 │ let g:lightline = {
11 │ \ 'colorscheme': 'PaperColor',
12 │ \ }
13 │
14 │ " lightline ale
15 │
16 │ " Register the components:
17 │ let g:lightline.component_expand = {
18 │ \ 'linter_checking': 'lightline#ale#checking',
19 │ \ 'linter_infos': 'lightline#ale#infos',
20 │ \ 'linter_warnings': 'lightline#ale#warnings',
21 │ \ 'linter_errors': 'lightline#ale#errors',
22 │ \ 'linter_ok': 'lightline#ale#ok',
23 │ \ }
24 │
25 │ " Set color to the components:
26 │ let g:lightline.component_type = {
27 │ \ 'linter_checking': 'right',
28 │ \ 'linter_infos': 'right',
29 │ \ 'linter_warnings': 'warning',
30 │ \ 'linter_errors': 'error',
31 │ \ 'linter_ok': 'right',
32 │ \ }
33 │
34 │ let g:lightline.component_function = {
35 │ \ 'gitbranch': 'gitbranch#name'
36 │ \ }
37 │
38 │ " Add the components to the lightline, for example to the right side:
39 │ let g:lightline.active = {
40 │ \ 'left': [ [ 'mode', 'paste' ],
41 │ \ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ],
42 │ \ 'right': [ ['fileformat', 'fileencoding', 'filetype' ], [ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok' ] ],
43 │ \ }
44 │
45 │ " icons
46 │ " let g:lightline#ale#indicator_checking = "\uf110"
47 │ " let g:lightline#ale#indicator_infos = "\uf129"
48 │ " let g:lightline#ale#indicator_warnings = "\uf071"
49 │ " let g:lightline#ale#indicator_errors = "\uf05e"
50 │ " let g:lightline#ale#indicator_ok = "\uf00c"
51 │
───────┴────────────────────────────────────────────────────────────────────────
───────┬────────────────────────────────────────────────────────────────────────
│ File: /Users/waldemar/.config/nvim/plugin/config/rainbow_main.vim
───────┼────────────────────────────────────────────────────────────────────────
1 │ let g:rainbow_active = 1
───────┴────────────────────────────────────────────────────────────────────────
───────┬────────────────────────────────────────────────────────────────────────
│ File: /Users/waldemar/.config/nvim/plugin/config/sunset.vim
───────┼────────────────────────────────────────────────────────────────────────
1 │ " London
2 │ let g:sunset_latitude = 51.5
3 │ let g:sunset_longitude = -0.1167
4 │
5 │ let g:sunset_utc_offset = 0 " London
6 │ " let g:sunset_utc_offset = 1 " London (British Summer Time)
7 │ " let g:sunset_utc_offset = 9 " Tokyo
───────┴────────────────────────────────────────────────────────────────────────
───────┬────────────────────────────────────────────────────────────────────────
│ File: /Users/waldemar/.config/nvim/plugin/config/vimwiki.vim
───────┼────────────────────────────────────────────────────────────────────────
1 │ let g:vimwiki_list = [{'path': '~/vimwiki/',
2 │ \ 'syntax': 'markdown', 'ext': '.md'}]
───────┴────────────────────────────────────────────────────────────────────────
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment