Major configuration rewrite, so... 2.0.0

This commit is contained in:
Mark Vainomaa 2017-01-27 21:46:05 +02:00
parent 53639d6c34
commit 1c9aff3028
2 changed files with 234 additions and 230 deletions

View File

@ -1,7 +1,6 @@
pkgname=neostrophic pkgname=neostrophic
pkgver=0.6 pkgver=2.0.0
pkgrel=1 pkgrel=1
epoch=1
pkgdesc="mikroskeem's personal neovim config (read: go away)" pkgdesc="mikroskeem's personal neovim config (read: go away)"
url="https://mikroskeem.eu/pages/neostrophic" url="https://mikroskeem.eu/pages/neostrophic"
arch=(any) arch=(any)

View File

@ -1,84 +1,17 @@
" mikroskeem's neovim config " mikroskeem's neovim config
" Bail if config is already loaded " Toggle preview
if exists("g:loaded_neostrophic") function! s:preview_toggle()
finish if &completeopt =~# "preview"
endif setlocal completeopt-=preview
let g:loaded_neostrophic = 1 pc
silent execute "!echo -n Preview turned off"
" neovim-qt Guifont command else
command -nargs=? Guifont call rpcnotify(0, 'Gui', 'SetFont', "<args>") | let g:Guifont="<args>" setlocal completeopt+=preview
silent execute "!echo -n Preview turned on"
" Set options
set wildmode=longest,list,full
set completeopt-=preview
set shortmess+=cI
set noshowmode
set shortmess+=I
set nostartofline
set wrap
set textwidth=0
set wrapmargin=0
set background=dark
set number
set numberwidth=3
if $DISPLAY != ''
set clipboard+=unnamedplus
endif
set showmatch
set smartcase
set ignorecase
set undofile
set undoreload=100
set viminfo+=n$HOME/.config/nvim/tmp/viminfo
set showtabline=0
set backup
set backupdir=$HOME/.config/nvim/tmp/backup/
set undodir=$HOME/.config/nvim/tmp/undo/
set directory=$HOME/.config/nvim/tmp/swap/
set title
set cursorline
let mapleader = ','
function! s:center_header(lines) abort
let longest_line = max(map(copy(a:lines), 'len(v:val)'))
let centered_lines = map(copy(a:lines),
\ 'repeat(" ", (&columns / 2) - (longest_line / 2)) . v:val')
return centered_lines
endfunction
function! s:mkdir_p(p)
if !isdirectory(expand(a:p))
call mkdir(expand(a:p), "p")
endif endif
endfunction endfunction
function! s:set_indent()
if &ft =~ 'yaml\|coffee\|vim\|jade'
set softtabstop=2 shiftwidth=2
endif
if &ft =~ 'make'
set shiftwidth=2 tabstop=2 noexpandtab
endif
endfunction
" Make missing dirs
silent! call s:mkdir_p(&undodir)
silent! call s:mkdir_p(&backupdir)
silent! call s:mkdir_p(&directory)
" Default indent settings
set softtabstop=4
set shiftwidth=4
set expandtab
set shiftround
set autoindent
set copyindent
" Function call below overrides previous options
" if opened filetype was defined in function
autocmd! FileType * call s:set_indent()
" Fake $MYVIMRC " Fake $MYVIMRC
function! s:fake_vimrc() function! s:fake_vimrc()
let $MYVIMRC=$HOME . "/.config/nvim/init.vim" let $MYVIMRC=$HOME . "/.config/nvim/init.vim"
@ -92,47 +25,224 @@ function! URP(info)
endif endif
endfunction endfunction
" Eyecandy: loads color scheme after it's installation :3 " Center text (for vim startify)
function! Load_color_scheme(info) function! s:center_header(lines) abort
if a:info.status == 'installed' let longest_line = max(map(copy(a:lines), 'len(v:val)'))
let s = printf("colorscheme %s", a:info.name) let centered_lines = map(copy(a:lines),
silent! execute s \ 'repeat(" ", (&columns / 2) - (longest_line / 2)) . v:val')
return centered_lines
endfunction
" mkdir -p
function! s:mkdir_p(p)
if !isdirectory(expand(a:p))
call mkdir(expand(a:p), "p")
endif endif
endfunction endfunction
" Toggle preview " Custom indendations
function! s:preview_toggle() function! s:set_indent()
if &completeopt =~# "preview" if &ft =~ 'yaml\|coffee\|vim\|jade'
setlocal completeopt-=preview set softtabstop=4 shiftwidth=4
pc endif
else if &ft =~ 'make'
setlocal completeopt+=preview set shiftwidth=2 tabstop=2 noexpandtab
endif endif
endfunction endfunction
" Plugin configurations " --- Start
let g:lightline = { if(!has("python3"))
\ 'active': { echo "You should install python neovim module. `pip install neovim`"
\ 'left': [['mode', 'paste',], ['readonly', 'modified', 'fugitive'], ['bufferinfo'], ['bufferbefore', 'buffercurrent', 'bufferafter']], end
\ },
\ 'component_expand': {
\ 'buffercurrent': 'lightline#buffer#buffercurrent2',
\ },
\ 'component_function': {
\ 'bufferbefore': 'lightline#buffer#bufferbefore',
\ 'bufferafter': 'lightline#buffer#bufferafter',
\ 'bufferinfo': 'lightline#buffer#bufferinfo',
\ 'fugitive': 'LlFugitive',
\ },
\ 'separator': { 'left': '>', 'right': '<' },
\ 'subseparator': { 'left': '>', 'right': '<' }
\ }
function! LlFugitive()
return exists('*fugitive#head') ? fugitive#head() : ''
endfunction
let g:lightline_buffer_readonly_icon = ''
" Plugins
call plug#begin('~/.config/nvim/neostrophic_plugins')
" --- Completion and syntax check engine
Plug 'Shougo/deoplete.nvim', {'do': function('URP')}
Plug 'scrooloose/syntastic'
Plug 'ervandew/supertab'
Plug 'Shougo/echodoc.vim'
" --- Syntax and completion engine components
Plug 'Shougo/context_filetype.vim'
"Plug 'Shougo/denite.nvim', {'do': function('URP')}
Plug 'Shougo/vimproc.vim', {'do' : 'make'}
" C++
Plug 'Rip-Rip/clang_complete', {'for': ['c', 'cpp']}
" Python
Plug 'zchee/deoplete-jedi', {'for': 'python'}
Plug 'jmcantrell/vim-virtualenv'
" Vimscript
Plug 'Shougo/neco-vim', {'for': 'vim'}
Plug 'Shougo/neco-syntax', {'for': 'vim'}
" JSON
Plug 'elzr/vim-json', {'for': 'json'}
" Java
"Plug 'artur-shaik/vim-javacomplete2', {'for': 'java'}
" Markdown
Plug 'gabrielelana/vim-markdown'
" Misc
Plug 'vim-scripts/nginx.vim', {'for': 'nginx'}
Plug 'Matt-Deacalion/vim-systemd-syntax', {'for': 'systemd'}
Plug 'PotatoesMaster/i3-vim-syntax', {'for': 'i3'}
" --- Git
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
" --- Themes
"Plug 'crater2150/vim-theme-chroma'
Plug 'justinmk/molokai'
" --- Workflow
" Startup screen
Plug 'mhinz/vim-startify'
" Undo tree
Plug 'sjl/gundo.vim'
" Status line
Plug 'itchyny/lightline.vim'
" Pathenses
Plug 'luochen1990/rainbow'
" Indendation aids
Plug 'Yggdroot/indentLine'
Plug 'godlygeek/tabular'
" Distraction-free
Plug 'junegunn/goyo.vim', {'on': 'Goyo'}
Plug 'junegunn/limelight.vim', {'on': 'Limelight'}
call plug#end()
" Apply color scheme
colorscheme molokai
" --- Neovim options
set updatetime=250
set wildmode=longest,list,full
set shortmess+=cI
set noshowmode
set nostartofline
set wrap
set textwidth=0
set wrapmargin=0
" Our leader is comma
let mapleader = ","
" Show line numbers
set number
set numberwidth=3
" Disable preview by default, because it is annoying imo
set completeopt-=preview
" Use X11 clipboard
if $DISPLAY != ''
set clipboard+=unnamedplus
endif
" Search options
set showmatch
set smartcase
set ignorecase
" Backup, undo and viminfo
set backup
set undofile
set undoreload=100
set viminfo+=n$HOME/.config/nvim/tmp/viminfo
set backupdir=$HOME/.config/nvim/tmp/backup/
set undodir=$HOME/.config/nvim/tmp/undo/
set directory=$HOME/.config/nvim/tmp/swap/
" Create missing directories
silent! call s:mkdir_p(&undodir)
silent! call s:mkdir_p(&backupdir)
silent! call s:mkdir_p(&directory)
set title
set cursorline
set showtabline=0
" Terminal tweaks
function! s:on_terminal_open()
setlocal nocursorline
endfunction
autocmd TermOpen * nested call <SID>on_terminal_open()
" Default indendation settings
set softtabstop=4
set shiftwidth=4
set expandtab
set shiftround
set autoindent
set copyindent
" Function call below overrides previous options
" if opened filetype was defined in function
autocmd! FileType * call s:set_indent()
" Neovim python
" Note: Read https://github.com/zchee/deoplete-jedi#virtual-environments
let g:python_host_prog = '/usr/bin/python2'
let g:python3_host_prog = '/usr/bin/python3'
" --- Plugin configurations
" Deoplete and echodoc
let g:deoplete#enable_at_startup = 1
let g:deoplete#enable_camel_case = 1
let g:echodoc_enable_at_startup = 1
" Rainbow
let g:rainbow_active = 1
let g:rainbow_conf = {'ctermfgs': ['red', 'lightgreen', 'lightred', 'lightblue', 'yellow']}
" Gitgutter
let g:gitgutter_map_keys = 0
let g:gitgutter_highlight_lines = 0
" indentLine
let g:indentLine_char = '┆'
" Startify
let g:startify_session_dir = '~/.config/nvim/startify-session'
let g:startify_custom_header = s:center_header(map(split(system('fortune | cowsay'), '\n'), '" ". v:val') + ['',''])
" Syntastic
let g:syntastic_enable_balloons = 1
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
let g:syntastic_mode_map = {
\ "mode": "active",
\ "active_filetypes": ["javascript", "python", "coffee", "jade", "yaml"],
\ "passive_filetypes": ["java", "c"]}
let g:syntastic_python_checkers = ['flake8', 'pylint']
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_yaml_checkers = ['yamllint', 'yamlxs']
let g:syntastic_cpp_checkers = ['clang_check']
let g:syntastic_cpp_compiler = 'clang++'
" Lightline
let g:lightline_buffer_readonly_icon = 'R'
let g:lightline_buffer_modified_icon = '+' let g:lightline_buffer_modified_icon = '+'
let g:lightline_buffer_active_buffer_left_icon = '[' let g:lightline_buffer_active_buffer_left_icon = '['
let g:lightline_buffer_active_buffer_right_icon = ']' let g:lightline_buffer_active_buffer_right_icon = ']'
@ -149,168 +259,63 @@ let g:lightline_buffer_minflen = 16
let g:lightline_buffer_minfextlen = 3 let g:lightline_buffer_minfextlen = 3
let g:lightline_buffer_reservelen = 20 let g:lightline_buffer_reservelen = 20
let g:molokai_original = 0 let g:lightline = {
let g:rehash256 = 1 \ 'active': {
\ 'left': [['mode', 'paste'], ['filename', 'readonly', 'modified', 'fugitive']],
let g:syntastic_enable_balloons = 1 \ },
let g:syntastic_always_populate_loc_list = 1 \ 'component_function': {
let g:syntastic_auto_loc_list = 1 \ 'fugitive': 'LlFugitive',
let g:syntastic_check_on_open = 1 \ },
let g:syntastic_check_on_wq = 0 \ 'separator': { 'left': '>', 'right': '<' },
let g:syntastic_mode_map = { \ 'subseparator': { 'left': '>', 'right': '<' }
\ "mode": "active", \ }
\ "active_filetypes": ["javascript", "python", "coffee", "jade", "yaml"], function! LlFugitive()
\ "passive_filetypes": ["java", "c"]} return exists('*fugitive#head') ? fugitive#head() : ''
let g:syntastic_python_checkers = ['flake8', 'pylint'] endfunction
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_yaml_checkers = ['yamllint', 'yamlxs']
let g:startify_session_dir = '~/.config/nvim/startify-session'
let g:startify_custom_header = s:center_header(map(split(system('fortune | cowsay'), '\n'), '" ". v:val') + ['',''])
let g:deoplete#enable_at_startup = 1
let g:deoplete#enable_camel_case = 1
let g:python3_host_prog = '/usr/bin/python3'
let g:python3_host_skip_check = 1
let g:NERDTreeHijackNetrw = 1
let g:gitgutter_map_keys = 0
let g:gitgutter_highlight_lines = 0
let g:echodoc_enable_at_startup = 1
let g:rainbow_active = 1
let g:rainbow_conf = {
\ 'ctermfgs': ['red', 'lightgreen', 'lightred', 'lightblue', 'yellow']}
" Plugins
call plug#begin('~/.config/nvim/neostrophic_plugins')
Plug 'tpope/vim-sensible'
Plug 'Konfekt/FastFold'
Plug 'Matt-Deacalion/vim-systemd-syntax', {'for': 'systemd'}
Plug 'PotatoesMaster/i3-vim-syntax', {'for': 'i3'}
Plug 'Shougo/context_filetype.vim'
Plug 'Shougo/deoplete.nvim', {'do': function('URP')}
Plug 'Shougo/echodoc.vim'
Plug 'Shougo/unite.vim', {'on': 'Unite' }
Plug 'Shougo/vimproc.vim', {'do': 'make'}
Plug 'airblade/vim-gitgutter'
Plug 'digitaltoad/vim-pug', {'for': ['jade', 'pug']}
Plug 'elzr/vim-json', {'for': 'json'}
Plug 'itchyny/lightline.vim'
Plug 'jelera/vim-javascript-syntax', {'for': 'javascript'}
Plug 'jmcantrell/vim-virtualenv'
Plug 'junegunn/goyo.vim', {'on': 'Goyo'}
Plug 'junegunn/limelight.vim', {'on': 'Limelight'}
Plug 'junegunn/vim-easy-align', {'on': 'EasyAlign'}
Plug 'justinmk/molokai', {'do': function('Load_color_scheme')}
Plug 'kchmck/vim-coffee-script', {'for': 'coffee'}
Plug 'luochen1990/rainbow'
Plug 'majutsushi/tagbar'
Plug 'mattn/gist-vim', {'on': 'Gist'}
Plug 'mattn/webapi-vim', {'on': 'Gist'}
Plug 'matze/vim-move'
Plug 'mhinz/vim-startify'
Plug 'mikroskeem/vim-sk-syntax', {'for': 'skript'}
Plug 'nelstrom/vim-markdown-folding', {'for': 'markdown'}
Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'}
Plug 'scrooloose/syntastic'
Plug 'taohex/lightline-buffer'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-markdown', {'for': 'markdown'}
Plug 'vim-scripts/nginx.vim', {'for': 'nginx'}
Plug 'wavded/vim-stylus', {'for': 'stylus'}
Plug 'Yggdroot/indentLine'
Plug 'zchee/deoplete-jedi'
call plug#end()
" Terminal
autocmd TermOpen * setlocal nocursorline
" Goyo
" Goyo & Lightline
function! s:on_goyo_enter() function! s:on_goyo_enter()
if exists('$TMUX')
silent !tmux set status off
endif
setlocal nocursorline setlocal nocursorline
Limelight Limelight
endfunction endfunction
function! s:on_goyo_leave() function! s:on_goyo_leave()
if exists('$TMUX')
silent !tmux set status on
endif
setlocal cursorline setlocal cursorline
Limelight! Limelight!
endfunction endfunction
autocmd! User GoyoEnter nested call <SID>on_goyo_enter() autocmd! User GoyoEnter nested call <SID>on_goyo_enter()
autocmd! User GoyoLeave nested call <SID>on_goyo_leave() autocmd! User GoyoLeave nested call <SID>on_goyo_leave()
" Markdown
" Keybinds let g:markdown_include_jekyll_support = 0
" Tab controls
nnoremap <silent> <C-Left> :tabprevious<CR>
nnoremap <silent> <C-Right> :tabnext<CR>
nnoremap <silent> <C-Up> :tabnew<CR>
nnoremap <silent> <C-Down> :tabclose<CR>
" ----------------
nnoremap <silent> <F2> :tabnew<CR>
nnoremap <silent> <A-F2> :tabclose<CR>
nnoremap <silent> <F3> :tabprevious<CR>
nnoremap <silent> <F4> :tabnext<CR>
" --- Keymaps
" Commonly used commands " Commonly used commands
" Undo
nnoremap <silent> <C-z> :u<CR> nnoremap <silent> <C-z> :u<CR>
" Quit
nnoremap <silent> <C-x> :q<CR>
" Just write
nnoremap <silent> <C-o> :w<CR> nnoremap <silent> <C-o> :w<CR>
" Quit without writing nnoremap <silent> <C-x> :q<CR>
nnoremap <silent> <C-A-x> :q!<CR> nnoremap <silent> <C-A-x> :q!<CR>
" Remove search highlighting
nnoremap <silent> <C-A-a> :noh<CR> nnoremap <silent> <C-A-a> :noh<CR>
" Preview toggle
nnoremap <silent> <Leader>p :call <SID>preview_toggle()<CR> nnoremap <silent> <Leader>p :call <SID>preview_toggle()<CR>
" F-line
nnoremap <F5> :so %<CR>
nnoremap <F6> :GundoToggle<CR>
nnoremap <F7> :term<CR>
nnoremap <F8> :Goyo<CR>
" Git
nmap <Leader>hr <Plug>GitGutterUndoHunk
nmap <Leader>hp <Plug>GitGutterPreviewHunk
" Shut up annoying stuff
nnoremap <silent> <C-A-f> :SyntasticToggleMode<CR>
nnoremap <silent> <Leader>p :call <SID>preview_toggle()<CR>
" Increase/decrease numbers with Alt key and A/X " Increase/decrease numbers with Alt key and A/X
nnoremap <A-a> <C-a> nnoremap <A-a> <C-a>
nnoremap <A-x> <C-x> nnoremap <A-x> <C-x>
" Commands from plugins " Terminal
" File listing
nnoremap <silent> <C-n> :NERDTreeToggle<CR>
" Gist
nnoremap <silent> <C-A-g> :Gist -p<CR>
" Toggle Syntastic
nnoremap <silent> <C-A-f> :SyntasticToggleMode<CR>
" Goyo mode
nnoremap <silent> <F5> :Goyo<CR>
" neovim term
nnoremap <silent> <F6> :term<CR>
" neovim terminal mode -> normal mode with Alt-q
tnoremap <A-q> <C-\><C-n> tnoremap <A-q> <C-\><C-n>
" Unite
nnoremap <silent> <F7> :Unite<CR>
" Show/hide tags
nnoremap <silent> <F8> :TagbarToggle<CR>
" vim-easy-align
" xnoremap / nnoremap won't work here somehow
xmap <leader>ga :EasyAlign<CR>
nmap <leader>ga :EasyAlign<CR>
" GitGutter
nmap <Leader>hr <Plug>GitGutterUndoHunk
nmap <Leader>hp <Plug>GitGutterPrevHunk
" Re-apply fake $MYVIMRC
silent! call s:fake_vimrc()
" Load color scheme (reuse function)
call Load_color_scheme({'status': 'installed', 'name': 'molokai'})