Skip to content

Instantly share code, notes, and snippets.

@clockworkpc
Created August 25, 2022 14:32
Show Gist options
  • Save clockworkpc/aace3b5244a8fa23727a9aff8aecbfdf to your computer and use it in GitHub Desktop.
Save clockworkpc/aace3b5244a8fa23727a9aff8aecbfdf to your computer and use it in GitHub Desktop.
Neovim Config File
"*****************************************************************************
"" CPC NEOVIM CONFIGURATION
"" Maintainer: Alexander JK Garber
"*****************************************************************************
"*****************************************************************************
"" Vim-PLug core
"*****************************************************************************
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
let g:vim_bootstrap_langs = "go,haskell,html,javascript,lisp,python,ruby,typescript"
let g:vim_bootstrap_editor = "nvim" " nvim or 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
" Required:
call plug#begin(expand('~/.config/nvim/plugged'))
"****************************************************************************
"" Project
"****************************************************************************
" Functional Start Screen
" Plug 'mhinz/vim-startify'
" Treeview file browser in VIM
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
" Plug 'MarSoft/nerdtree-grep-plugin'
" Status bar above and below
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Show changed lines in gutter
Plug 'airblade/vim-gitgutter'
" Search for strings in files
Plug 'vim-scripts/grep.vim'
"GVim-only colour schemes
Plug 'vim-scripts/CSApprox'
" Fuzzy file search
if isdirectory('/usr/local/opt/fzf')
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
else
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
endif
let g:make = 'gmake'
if exists('make')
let g:make = 'make'
endif
" Find and Replace
Plug 'brooth/far.vim'
" Interactive command execution
Plug 'Shougo/vimproc.vim', {'do': g:make}
"" Vim-Session
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'
" ctags
" Plug 'ludovicchabant/vim-gutentags'
" Plug 'craigemery/vim-autotag'
"codequery
" Plug 'Shougo/unite.vim'
" Plug 'devjoe/vim-codequery'
"grep replace
Plug 'skwp/greplace.vim'
"view images
Plug 'ashisha/image.vim'
"Reload files changed on disk
Plug 'djoshea/vim-autoread'
" Fountain plugin
Plug 'kblin/vim-fountain'
" Close buffers
Plug 'Asheq/close-buffers.vim'
" Conquer of Code (Autocomplete)
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Autosave sessions
Plug 'tpope/vim-obsession'
"Use Vim in the browser
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
"****************************************************************************
"" Editor (NORMAL MODE ONLY)
"****************************************************************************
" Comment out lines with gcc or gc in visual mode
Plug 'tpope/vim-commentary'
" Tag viewer for class and method definitions
Plug 'majutsushi/tagbar'
" Display thin vertical lines for indentations
Plug 'Yggdroot/indentLine'
" Repeat a plug-in command
Plug 'tpope/vim-repeat'
" Improved clipping of text
Plug 'svermeulen/vim-easyclip'
"Replace double quotes, single quotes, etc
Plug 'tpope/vim-surround'
"Split single line to multiline and visa versa
Plug 'AndrewRadev/splitjoin.vim'
"Word Motion
" Plug 'chaoren/vim-wordmotion'
"Resize Windows
Plug 'simeji/winresizer'
"****************************************************************************
"" Editor (INSERT MODE ONLY)
"****************************************************************************
"Autocomplete
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'ervandew/supertab'
"Snippets
Plug 'sirver/UltiSnips'
Plug 'honza/vim-snippets'
" Autocomplete brackets, quotes, etc.
Plug 'Raimondi/delimitMate'
"Markdown tables
Plug 'dhruvasagar/vim-table-mode'
"
"Pairs of handy bracket mappings
Plug 'tpope/vim-unimpaired'
"Horizontal navigation"
Plug 'unblevable/quick-scope'
"Automatic bullet and numbered lists
Plug 'dkarter/bullets.vim'
"Automatic newline and indentation between brackets
Plug 'jiangmiao/auto-pairs'
"Merge git conflicts
Plug 'christoomey/vim-conflicted'
"****************************************************************************
"" Editor (VISUAL MODE ONLY)
"****************************************************************************
"Select a ruby block in VISUAL mode
Plug 'nelstrom/vim-textobj-rubyblock'
" dependency of vim-textobj-rubyblock
Plug 'kana/vim-textobj-user'
"Scratch buffer
" Plug 'mtth/scratch.vim'
"****************************************************************************
"" Editor (COMBINED MODES)
"****************************************************************************
"Make Goyo even nicer
Plug 'amix/vim-zenroom2'
"Code linting
Plug 'dense-analysis/ale'
Plug 'prettier/vim-prettier'
"OrgMode for VIM
Plug 'jceb/vim-orgmode'
"Atomesque coloures
Plug 'joshdick/onedark.vim'
"Distraction-free editing
Plug 'junegunn/goyo.vim'
"Markdown preview
" Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
" Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
" Plug 'iamcco/markdown-preview.nvim'
Plug 'suan/vim-instant-markdown', {'for': 'markdown', 'do': 'yarn install'}
"Floating Terminal
Plug 'voldikss/vim-floaterm'
"Cucumber syntax highlighting
Plug 'barboza/vim-cucumber-string-highlight'
""****************************************************************************
"" Version Control
"****************************************************************************
" Git wrapper
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb' " required by fugitive to :Gbrowse
" GraphQL syntax highlighting
Plug 'jparise/vim-graphql'
"***************************************************************************
"" Ruby and Rails
"***************************************************************************
"Refactor
Plug 'ecomba/vim-ruby-refactoring'
Plug 'thoughtbot/vim-rspec'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-cucumber'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-rake'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-rbenv'
Plug 'thoughtbot/vim-rspec'
Plug 'vim-ruby/vim-ruby'
"Ruby/Rails/RSpec documentation
" Plug 'lucapette/vim-ruby-doc'
" Toggle Ruby do/end and {}
Plug 'jgdavey/vim-blockle'
"***************************************************************************
"" Other Languages
"***************************************************************************
" go
"" Go Lang Bundle
Plug 'fatih/vim-go', {'do': ':GoInstallBinaries'}
" haskell
"" Haskell Bundle
Plug 'eagletmt/neco-ghc'
Plug 'dag/vim2hs'
Plug 'pbrisbin/vim-syntax-shakespeare'
" html
"" HTML Bundle
Plug 'hail2u/vim-css3-syntax'
" Plug 'gorodinskiy/vim-coloresque'
Plug 'tpope/vim-haml'
Plug 'mattn/emmet-vim'
Plug 'zeekay/vim-beautify'
" javascript
"" Javascript Bundle
Plug 'jelera/vim-javascript-syntax'
" lisp
"" Lisp Bundle
Plug 'vim-scripts/slimv.vim'
" python
"" Python Bundle
Plug 'davidhalter/jedi-vim'
Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'}
" typescript
Plug 'leafgarland/typescript-vim'
Plug 'HerringtonDarkholme/yats.vim'
"VimBeGood (Primeagen)
" Plug 'ThePrimeagen/vim-be-good', {'do': './install.sh'}
"FISH Scripting
Plug 'dag/vim-fish'
"Writing Tools
Plug 'preservim/vim-pencil'
Plug 'dbmrq/vim-ditto'
Plug 'honza/writer.vim'
Plug 'mattn/vim-metarw-gdrive'
"*****************************************************************************
call plug#end()
"***************************************************************************
"" Core VIM Keybindings
"***************************************************************************"
" Map leader to ,
let mapleader=','
"map LocalLeader to \\
let maplocalleader = "\\"
"Left (h) => [h]
noremap h h
"Up (j) => [t]
noremap t gj
"Down (k) => [n]
noremap n gk
"Right (l) => [s]
noremap s l
"End of line ($) => [-]
noremap - $
"Start of line (^) => [_]
noremap _ ^
"Jump to letter before (t) => [j]
noremap k t
"Sentences
noremap $ s
"m is shadowed by easyclip plugin
noremap gm m
" j/J moves between search mappings
nnoremap j n
nnoremap J N
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
" nnoremap j nzzzv
" nnoremap J Nzzzv
"Move text down
nnoremap <A-t> :m .+1<CR>==
inoremap <A-t> <Esc>:m .+1<CR>==gi
vnoremap <A-t> :m '>+1<CR>gv=gv
"Move text up
nnoremap <A-n> :m .-2<CR>==
inoremap <A-n> <Esc>:m .-2<CR>==gi
vnoremap <A-n> :m '<-2<CR>gv=gv
"*****************************************************************************
"" Mappings
"*****************************************************************************
"" Split
noremap <Leader>h :<C-u>split<CR>
" New buffer rather than the current file
noremap <Leader>v :<C-u>vnew<CR>
" Current file rather than a new buffer
" noremap <Leader>v :<C-u>vsplit<CR>
"*****************************************************************************
"Customised VIM
"*****************************************************************************
"Show how many lines yanked, inter alia
set report=0
"Hybrid line numbers
:set number relativenumber
:augroup numbertoggle
: autocmd!
: autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
: autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
:augroup END
"More natural movement in INSERT mode
behave mswin
"*****************************************************************************
"" Custom Bindings
"*****************************************************************************
"Fix indentation for the whole file
nnoremap <F7> gg=G<C-o><C-o>
" Bind F8 to fixing problems with ALE
nmap <F8> <Plug>(ale_fix)
"Force filetype 'yaml' for yml files
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml foldmethod=manual
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" autocmd BufNewFile,BufRead *.yml set ft=yaml
"Stop line wrap from breaking words
set linebreak
"Skip out of brackets
inoremap <C-e> <C-o>A
"Replace all
nnoremap S :%s///g<Left><Left><Left>
"Jump to next occurrence in INSERT mode
imap <C-j> <Esc>jcaw
"Replace all within a visual selection
" vnoremap S :s/\%V//g<Left><Left><Left>
"Ctrl-A for select all
" vnnoremap <C-a> ggVG
"Replace all matching strings in visual selection
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
" Close all hidden buffers
nnoremap <silent> <C-q> :Bdelete menu<CR>
function! ALEFixFast()
syntax off
exec "ALEFix"
syntax on
endfunction
"Save file, even if no changes
nor <silent> <Leader>w :w<CR>
vnoremap <silent> <C-w> <C-C>:update<CR>
"Close all buffers and quit Neovim
noremap <Leader>' :qall<CR>
"*****************************************************************************
"" Abbreviations
"*****************************************************************************
"" no one is really happy until you have this shortcuts
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall
"*****************************************************************************
"" ALE
"*****************************************************************************
" LINTERS
let g:ale_linters = {
\ 'gql': ['prettier'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\ 'vim': ['vint'],
\}
function! SettingsTurnOff()
"Turns syntax off only in current buffer
exec "syntax clear"
" exec "set nocursorcolumn"
" exec "set nocursorline"
" exec "set norelativenumber"
endfunction
function! SettingsTurnOn()
exec "syntax on"
" exec "set number relativenumber"
exec "AirlineRefresh"
endfunction
augroup YourGroup
autocmd!
autocmd User ALEFixPre call SettingsTurnOff()
autocmd User ALEFixPost call SettingsTurnOn()
augroup END
" FIXERS
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\}
let g:ale_lint_on_enter = 1
let g:ale_completion_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %(code): %%s [%severity%]'
let g:airline#extensions#ale#enabled = 1
" let g:ale_ruby_rubocop_executable = 'rubocop-daemon exec -- --auto-correct'
" set omnifunc=ale#completion#OmniFunc
"*****************************************************************************
"" Autocmd Rules, Functions
"*****************************************************************************
"" Functions
if !exists('*s:setupWrapping')
function s:setupWrapping()
set wrap
set wm=2
set textwidth=80
endfunction
endif
"*****************************************************************************
"" Autocmd Rules
"*****************************************************************************
"" The PC is fast enough, do syntax highlight syncing from start unless 200 lines
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=200
augroup END
"" Remember cursor position
augroup vimrc-remember-cursor-position
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
"" txt
augroup vimrc-wrapping
autocmd!
autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
augroup END
"" make/cmake
augroup vimrc-make-cmake
autocmd!
autocmd FileType make setlocal noexpandtab
autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
augroup END
set autoread
"*****************************************************************************
"" AUTO PAIRS
"*****************************************************************************
" Jump outside '"({
if !exists('g:AutoPairsShortcutJump')
let g:AutoPairsShortcutJump = '<C-l>'
endif
"*****************************************************************************
"" Buffers, Tabs, Windows
"*****************************************************************************
"" Buffer nav
noremap <leader>x :bn<CR>
"" Close buffer
noremap <leader>c :bd<CR>
"" Enable hidden buffers
" set hidden
"" Switching windows
noremap <C-h> <C-w>h
noremap <C-t> <C-w>j
noremap <C-n> <C-w>k
noremap <C-s> <C-w>l
"" Tabs
nnoremap <Tab> gt
nnoremap <S-Tab> gT
nnoremap <silent> <S-t> :tabnew<CR>
"Scratch buffer
function! Scratch()
tabnew
noswapfile hide enew
setlocal buftype=nofile
setlocal bufhidden=hide
"setlocal nobuflisted
"lcd ~
file scratch
endfunction
"*****************************************************************************
"" COC
"*****************************************************************************
" 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
" let g:coc_global_extensions = ['coc-solargraph']
"*****************************************************************************
"" Copy/Paste/Cut
"*****************************************************************************
if has('unnamedplus')
set clipboard=unnamed,unnamedplus
endif
noremap YY "+y<CR>
noremap <leader>p "+gP<CR>
noremap XX "+x<CR>
if has('macunix')
" pbcopy for OSX copy/paste
vmap <C-x> :!pbcopy<CR>
vmap <C-c> :w !pbcopy<CR><CR>
endif
"*****************************************************************************
"" deoplete
"*****************************************************************************
""deoplete
let g:deoplete#enable_at_startup = 1
let g:auto_complete_popup = "manual"
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ deoplete#mappings#manual_complete()
function! s:check_back_space() abort "{{{
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction"}}}
"*****************************************************************************
"" neosnippet
"*****************************************************************************
" " Plugin key-mappings.
" " Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <C-k> <Plug>(neosnippet_expand_or_jump)
" smap <C-k> <Plug>(neosnippet_expand_or_jump)
" xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
" if has('conceal')
" set conceallevel=2 concealcursor=niv
" endif
" " To use Honza's Vim Snippets
" let g:neosnippet#snippets_directory='~/.config/nvim/plugged/vim-snippets/snippets'
"*****************************************************************************
"" Encoding
"*****************************************************************************
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
let g:far#enable_undo=1
"*****************************************************************************
"" fish
"*****************************************************************************
if &shell =~# 'fish$'
set shell=sh
endif
"*****************************************************************************
"" fzf
"*****************************************************************************
set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
let $FZF_DEFAULT_COMMAND = "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'dist/**' -prune -o -type f -print -o -type l -print 2> /dev/null"
" nnoremap <silent> <leader>b :Buffers<CR>
nnoremap <silent> <leader>e :FZF -m<CR>
"Recovery commands from history through FZF
nmap <leader>y :History:<CR>
"NOTE: To open a file in a new tab CTRL-V, CTRL-X, or CTRL-T
"*****************************************************************************
"" General Settings
"*****************************************************************************
"Use `onedark` colour scheme
" colorscheme onedark
colo onedark
"Syntax highlighting from start unless 1000 lines (instead of 200)
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=1000
augroup END
"Refresh file when changed on disk
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI *
\ if mode() !~ '\v(c|r.?|!|t)' && getcmdwintype() == '' | checktime | endif
"Autowrite
set autowriteall
" :set tabstop=2
" :set shiftwidth=2
" :set expandtab
" Folding
set fdm=syntax
set nofoldenable
" set foldlevel=0
" Built-in Neovim autocomplete
cnoremap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
"NERDTree can modify files
set modifiable
"Add Cucumber filetype detection
au BufRead,BufNewFile *.cucumber set filetype=cucumber
"Various completion plugins require this
filetype plugin on
"Omni completion
" set omnifunc=syntaxcomplete#Complete
"Spell check
nnoremap <F10> :set spell! spelllang=en_gb,lt,fr,he!<CR>
"Center screen when going into INSERT mode
" autocmd InsertEnter * norm zz
"Thin line cursor in INSERT mode
highlight Cursor guifg=white guibg=black
highlight iCursor guifg=white guibg=steelblue
set guicursor=n-v-c:block-Cursor
set guicursor=i:ver25-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait10
"Highlight current line
autocmd InsertEnter,InsertLeave * set cul!
"Auotmatically split to the right
set splitright
"*****************************************************************************
"" Git
"*****************************************************************************
noremap <Leader>ga :Gwrite<CR>
noremap <Leader>gc :Gcommit<CR>
noremap <Leader>gsh :Gpush<CR>
noremap <Leader>gll :Gpull<CR>
noremap <Leader>gs :Gstatus<CR>
noremap <Leader>gb :Gblame<CR>
noremap <Leader>gd :Gvdiff<CR>
noremap <Leader>gr :Gremove<CR>
"" Open current line on GitHub
nnoremap <Leader>o :.Gbrowse<CR>
set diffopt+=vertical
"*****************************************************************************
"" grep.vim
"*****************************************************************************
" grep.vim
nnoremap <silent> <leader>f :Rgrep<CR>
let Grep_Default_Options = '-IR'
let Grep_Skip_Files = '*.log *.db'
let Grep_Skip_Dirs = '.git node_modules'
"*****************************************************************************
"" HTML
"*****************************************************************************
" for html files, 2 spaces
autocmd Filetype html setlocal ts=2 sw=2 expandtab
"View HTML Text
function! ViewHtmlText(url)
if !empty(a:url)
new
setlocal buftype=nofile bufhidden=hide noswapfile
execute 'r !elinks ' . a:url . ' -dump -dump-width ' . winwidth(0)
1d
endif
endfunction
" Save and view text for current html file.
nnoremap <Leader>H :update<Bar>call ViewHtmlText(expand('%:p'))<CR>
" " View text for visually selected url.
vnoremap <Leader>h y:call ViewHtmlText(@*)<CR>
" View text for URL from clipboard.
" On Linux, use @* for current selection or @+ for text in clipboard.
nnoremap <Leader>h :call ViewHtmlText(@+)<CR>
"*****************************************************************************
"" Emmet
"*****************************************************************************
" let g:user_emmet_install_global = 0
" autocmd FileType html,css,erb EmmetInstall
let g:user_emmet_leader_key=','
"*****************************************************************************
"" Indentations, Tabs, Whitespaces
"*****************************************************************************
"" Fix backspace indent
set backspace=indent,eol,start
"" Tabs. May be overridden by autocmd rules
set tabstop=2
set softtabstop=0
set shiftwidth=2
set expandtab
" remove trailing whitespaces
command! FixWhitespace :%s/\s\+$//e
"Fix indentation for the whole file
" nnoremap <F7> gg=G<C-o><C-o>
"*****************************************************************************
"" JavaScript
"*****************************************************************************
" javascript
let g:javascript_enable_domhtmlcss = 1
" vim-javascript
augroup vimrc-javascript
autocmd!
autocmd FileType javascript setl tabstop=4|setl shiftwidth=4|setl expandtab softtabstop=4
augroup END
"*****************************************************************************
"" LanguageClient-Neovim
"*****************************************************************************
" Tell the language client to use the default IP and port
" that Solargraph runs on
" let g:LanguageClient_serverCommands = {
" \ 'ruby': ['tcp://localhost:7658']
" \ }
" Don't send a stop signal to the server when exiting vim.
" This is optional, but I don't like having to restart Solargraph
" every time I restart vim.
" let g:LanguageClient_autoStop = 0
" Configure ruby omni-completion to use the language client:
" autocmd FileType ruby setlocal omnifunc=LanguageClient#complete
" Required for operations modifying multiple buffers like rename.
" set hidden
" let g:LanguageClient_serverCommands = {
" \ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
" \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
" \ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
" \ 'python': ['/usr/local/bin/pyls'],
" \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'],
" \ }
" nnoremap <F5> :call LanguageClient_contextMenu()<CR>
" " Or map each action separately
" nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
" nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
" nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
"*****************************************************************************
"" Macros
"*****************************************************************************
nnoremap <leader>gcr If<esc>A # rubocop:disable RSpec/Focus<esc>
nnoremap <leader>sal gg<esc>O$seeds_already_loaded = true<esc><C-o>
nnoremap <leader>gms gg<esc>O$minimal_seeds = true<esc><C-o>
"*****************************************************************************
"" Markdown
"*****************************************************************************
"Markdown plugin
" filetype plugin on
let g:vim_markdown_conceal = 0
let g:vim_markdown_conceal_code_blocks = 0
"Uncomment to override defaults:
"let g:instant_markdown_slow = 1
"let g:instant_markdown_autostart = 0
"let g:instant_markdown_open_to_the_world = 1
"let g:instant_markdown_allow_unsafe_content = 1
"let g:instant_markdown_allow_external_content = 0
"let g:instant_markdown_mathjax = 1
"let g:instant_markdown_logfile = '/tmp/instant_markdown.log'
"let g:instant_markdown_autoscroll = 0
"let g:instant_markdown_port = 8888
"let g:instant_markdown_python = 1
"MarkdownPreview
" set to 1, nvim will open the preview window after entering the markdown buffer
" default: 0
let g:mkdp_auto_start = 1
" set to 1, the nvim will auto close current preview window when change
" from markdown buffer to another buffer
" default: 1
let g:mkdp_auto_close = 1
" set to 1, the vim will refresh markdown when save the buffer or
" leave from insert mode, default 0 is auto refresh markdown as you edit or
" move the cursor
" default: 0
let g:mkdp_refresh_slow = 0
" set to 1, the MarkdownPreview command can be use for all files,
" by default it can be use in markdown file
" default: 0
let g:mkdp_command_for_global = 0
" set to 1, preview server available to others in your network
" by default, the server listens on localhost (127.0.0.1)
" default: 0
let g:mkdp_open_to_the_world = 0
" use custom IP to open preview page
" useful when you work in remote vim and preview on local browser
" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9
" default empty
let g:mkdp_open_ip = ''
" specify browser to open preview page
" default: ''
let g:mkdp_browser = ''
" set to 1, echo preview page url in command line when open preview page
" default is 0
let g:mkdp_echo_preview_url = 0
" a custom vim function name to open preview page
" this function will receive url as param
" default is empty
let g:mkdp_browserfunc = ''
" options for markdown render
" mkit: markdown-it options for render
" katex: katex options for math
" uml: markdown-it-plantuml options
" maid: mermaid options
" disable_sync_scroll: if disable sync scroll, default 0
" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle'
" middle: mean the cursor position alway show at the middle of the preview page
" top: mean the vim top viewport alway show at the top of the preview page
" relative: mean the cursor position alway show at the relative positon of the preview page
" hide_yaml_meta: if hide yaml metadata, default is 1
" sequence_diagrams: js-sequence-diagrams options
" content_editable: if enable content editable for preview page, default: v:false
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1,
\ 'sequence_diagrams': {},
\ 'flowchart_diagrams': {},
\ 'content_editable': v:false
\ }
" use a custom markdown style must be absolute path
" like '/Users/username/markdown.css' or expand('~/markdown.css')
let g:mkdp_markdown_css = ''
" use a custom highlight style must absolute path
" like '/Users/username/highlight.css' or expand('~/highlight.css')
let g:mkdp_highlight_css = ''
" use a custom port to start server or random for empty
let g:mkdp_port = ''
" preview page title
" ${name} will be replace with the file name
let g:mkdp_page_title = '「${name}」'
"*****************************************************************************
"" NERDTree
"*****************************************************************************
"" NERDTree configuration
let g:NERDTreeChDirMode=2
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let g:NERDTreeShowBookmarks=1
let g:nerdtree_tabs_focus_on_files=1
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
let g:NERDTreeWinSize = 50
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
nnoremap <silent> <F2> :NERDTreeFind<CR>
nnoremap <silent> <F3> :NERDTreeToggle<CR>
let g:NERDTreeMapOpenInTab = "l"
"Close NERDTree when you open a file
let NERDTreeQuitOnOpen = 1
"Prettify NERDTree
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
" autocmd FileType nerdtree setlocal noreadonly
"*****************************************************************************
"" polyglot
"*****************************************************************************
" Syntax highlight
" Default highlight is better than polyglot
let g:polyglot_disabled = ['python']
let python_highlight_all = 1
"*****************************************************************************
"" Python
"*****************************************************************************
" vim-python
augroup vimrc-python
autocmd!
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 colorcolumn=79
\ formatoptions+=croq softtabstop=4
\ cinwords=if,elif,else,for,while,try,except,finally,def,class,with
augroup END
"*****************************************************************************
"" jedi-vim
"*****************************************************************************
let g:jedi#popup_on_dot = 0
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_definitions_command = "<leader>d"
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#rename_command = "<leader>r"
let g:jedi#show_call_signatures = "0"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#smart_auto_mappings = 0
"*****************************************************************************
"" ripgrep
"*****************************************************************************
if executable('rg')
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
set grepprg=rg\ --vimgrep
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
endif
"*****************************************************************************
"" rspec.vim
"*****************************************************************************
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
"Prepend `bundle exec`
let g:rspec_command = "!bundle exec rspec {spec}"
"*****************************************************************************
"" Ruby
"*****************************************************************************
"Omnicomplete
let g:ruby_host_prog = '~/.rbenv/shims/neovim-ruby-host'
let g:ruby_path = system('echo $HOME/.rbenv/shims')
" ruby
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
augroup vimrc-ruby
autocmd!
autocmd BufNewFile,BufRead *.rb,*.rbw,*.gemspec setlocal filetype=ruby
autocmd FileType ruby set tabstop=2|set shiftwidth=2|set expandtab softtabstop=2
augroup END
" For ruby refactory
if has('nvim')
runtime! macros/matchit.vim
else
packadd! matchit
endif
" Ruby refactory
nnoremap <leader>rap :RAddParameter<cr>
nnoremap <leader>rcpc :RConvertPostConditional<cr>
nnoremap <leader>rel :RExtractLet<cr>
vnoremap <leader>rec :RExtractConstant<cr>
vnoremap <leader>relv :RExtractLocalVariable<cr>
nnoremap <leader>rit :RInlineTemp<cr>
vnoremap <leader>rrlv :RRenameLocalVariable<cr>
vnoremap <leader>rriv :RRenameInstanceVariable<cr>
vnoremap <leader>rem :RExtractMethod<cr>
"Run RSpec in Tmux
" map <Leader>rt :w<cr>:call RunCurrentTest('!ts be rspec')<CR>
" Thoughtbot Vim-RSpec
let g:rspec_command = "Dispatch bundle exec rspec {spec}"
" let g:rspec_command = "!bundle exec rspec {spec}"
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
" map <LocalLeader>s :e db/schema.rb<CR>
"*****************************************************************************
"" Search
"*****************************************************************************
"" Clean search (highlight)
nnoremap <silent> <leader><space> :noh<cr>
"" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
set fileformats=unix,dos,mac
if exists('$SHELL')
set shell=$SHELL
else
set shell=/bin/sh
endif
"Search for visually selected text
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
"*****************************************************************************
"" Session Management
"*****************************************************************************
nnoremap <leader>so :OpenSession<Space>
nnoremap <leader>ss :SaveSession<Space>
nnoremap <leader>sd :DeleteSession<CR>
nnoremap <leader>sc :CloseSession<CR>
let g:session_directory = "~/.config/nvim/session"
let g:session_autoload = "prompt"
let g:session_autosave = "yes"
let g:session_autosave_periodic = 1
let g:session_command_aliases = 1
let g:session_autosave_silent = 1
"*****************************************************************************
"" The Silver Searcher
"*****************************************************************************
if executable('ag')
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
set grepprg=ag\ --nogroup\ --nocolor
endif
let g:startify_session_dir = '~/.config/nvim/session'
let g:startify_lists = [
\ { 'type': 'files', 'header': [' Files'] },
\ { 'type': 'dir', 'header': [' Current Directory '. getcwd()] },
\ { 'type': 'sessions', 'header': [' Sessions'] },
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
\ ]
let g:startify_bookmarks = [
\ { 'i': '~/.config/nvim/init.vim' },
\ '~/Development/inspiregroup/chameleon/creator/services/creator-backend',
\ '~/Development/publish/clockworkpc.github.io',
\ '~/Development/inspiregroup/chameleon/collect',
\ ]
let g:startify_session_autoload = 1
let g:startify_fortune_use_unicode = 1
let g:startify_session_persistence = 1
let g:startify_enable_special = 0
"*****************************************************************************
"" Tagbar
"*****************************************************************************
nmap <silent> <F4> :TagbarToggle<CR>
let g:tagbar_autofocus = 1
let g:tagbar_type_ruby = {
\ 'kinds' : [
\ 'm:modules',
\ 'c:classes',
\ 'd:describes',
\ 'C:contexts',
\ 'f:methods',
\ 'F:singleton methods'
\ ]
\ }
"*****************************************************************************
"" Terminal Emulation
"*****************************************************************************
" terminal emulation
nnoremap <silent> <leader>sh :terminal<CR>
"Open a terminal in a new tab
map <silent> <M-C-N> :tabnew <bar> :terminal<CR>
"*****************************************************************************
"" textobj-rubyblock
"*****************************************************************************
runtime macros/matchit.vim
set nocompatible
if has("autocmd")
filetype indent plugin on
endif
let g:textobj_ruby_more_mappings = 1
"*****************************************************************************
"" Typescript
"*****************************************************************************
" typescript
let g:yats_host_keyword = 1
"*****************************************************************************
"" UltiSnips
"*****************************************************************************
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
" let g:UltiSnipsExpandTrigger="<tab>"
" let g:UltiSnipsJumpForwardTrigger="<c-b>"
" let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" let g:UltiSnipsEditSplit="vertical"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
let g:UltiSnipsEditSplit="vertical"
" let g:UltiSnipsSnippetDirectories=["UltiSnips", "myUltiSnips"]
"*****************************************************************************
"" vim-airline
"*****************************************************************************
let g:airline_theme = 'powerlineish'
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline#extensions#tagbar#enabled = 1
let g:airline_skip_empty_sections = 1
"python
let g:airline#extensions#virtualenv#enabled = 1
"*****************************************************************************
"" Vimroom
"*****************************************************************************
"Vimroom
let g:goyo_width=100
let g:goyo_margin_top = 2
let g:goyo_margin_bottom = 2
nnoremap <silent> <leader>z :Goyo<cr>
"*****************************************************************************
"" vim-ruby-doc
"*****************************************************************************
" For some reason this plugin doesn't work anymore,
" so I hacked together the same functionality, using its example.
" Replace 'firefox' with whatever command you need instead.
let g:ruby_doc_url_template="http://rubydoc.info/search/stdlib/core?q=%"
let g:rails_doc_url_template="http://api.rubyonrails.org/?q=%"
let g:rspec_doc_url_template='https://www.relishapp.com/rspec/search?query=%'
function! AnyRDoc(url_template)
if &ft =~ "ruby"
else
return
endif
let s:wordUnderCursor = expand("<cword>")
let s:url = substitute(a:url_template, "%", s:wordUnderCursor, "g")
let s:cmd = "!firefox \"" . s:url . "\""
execute s:cmd
endfunction
map RB :call AnyRDoc(ruby_doc_url_template)<CR>
map RR :call AnyRDoc(rails_doc_url_template)<CR>
map RS :call AnyRDoc(rspec_doc_url_template)<CR>
"*****************************************************************************
"" visualbell
"*****************************************************************************
" Disable visualbell
set noerrorbells visualbell t_vb=
if has('autocmd')
autocmd GUIEnter * set visualbell t_vb=
endif
"*****************************************************************************
"" Visual Mode
"*****************************************************************************
"" Vmap for maintain Visual Mode after shifting > and <
vmap < <gv
vmap > >gv
"" Move visual block
" vnoremap J :m '>+1<CR>gv=gv
" vnoremap K :m '<-2<CR>gv=gv
"*****************************************************************************
"" Visual Settings
"*****************************************************************************
syntax on
set ruler
set number
let no_buffers_menu=1
set mousemodel=popup
set t_Co=256
set guioptions=egmrti
set gfn=Monospace\ 10
if has("gui_running")
if has("gui_mac") || has("gui_macvim")
set guifont=Menlo:h12
set transparency=7
endif
else
let g:CSApprox_loaded = 1
" IndentLine
let g:indentLine_enabled = 1
let g:indentLine_concealcursor = 0
let g:indentLine_char = '┆'
let g:indentLine_faster = 1
endif
"" Disable the blinking cursor.
set gcr+=a:blinkon0
set scrolloff=3
"" Status bar
set laststatus=2
"" Use modeline overrides
set modeline
set modelines=10
set title
set titleold="Terminal"
set titlestring=%F
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
if exists("*fugitive#statusline")
set statusline+=%{fugitive#statusline()}
endif
"*****************************************************************************
"" XML
"*****************************************************************************
function! DoFormatXML()
:%s/></>\r</g
:0
=:$
endfunction
com! FormatXML call DoFormatXML()
"*****************************************************************************
"" YAML
"*****************************************************************************
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
set foldlevelstart=20
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'
" let g:ale_lint_on_text_changed = 'never'
"*****************************************************************************
"" CPC NEOVIM CONFIGURATION
"" Maintainer: Alexander JK Garber
"*****************************************************************************
"*****************************************************************************
"" Vim-PLug core
"*****************************************************************************
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
let g:vim_bootstrap_langs = "go,haskell,html,javascript,lisp,python,ruby,typescript"
let g:vim_bootstrap_editor = "nvim" " nvim or 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
" Required:
call plug#begin(expand('~/.config/nvim/plugged'))
"****************************************************************************
"" Project
"****************************************************************************
" Functional Start Screen
" Plug 'mhinz/vim-startify'
" Treeview file browser in VIM
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
" Plug 'MarSoft/nerdtree-grep-plugin'
" Status bar above and below
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Show changed lines in gutter
Plug 'airblade/vim-gitgutter'
" Search for strings in files
Plug 'vim-scripts/grep.vim'
"GVim-only colour schemes
Plug 'vim-scripts/CSApprox'
" Fuzzy file search
if isdirectory('/usr/local/opt/fzf')
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
else
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
endif
let g:make = 'gmake'
if exists('make')
let g:make = 'make'
endif
" Find and Replace
Plug 'brooth/far.vim'
" Interactive command execution
Plug 'Shougo/vimproc.vim', {'do': g:make}
"" Vim-Session
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'
" ctags
" Plug 'ludovicchabant/vim-gutentags'
" Plug 'craigemery/vim-autotag'
"codequery
" Plug 'Shougo/unite.vim'
" Plug 'devjoe/vim-codequery'
"grep replace
Plug 'skwp/greplace.vim'
"view images
Plug 'ashisha/image.vim'
"Reload files changed on disk
Plug 'djoshea/vim-autoread'
" Fountain plugin
Plug 'kblin/vim-fountain'
" Close buffers
Plug 'Asheq/close-buffers.vim'
" Conquer of Code (Autocomplete)
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Autosave sessions
Plug 'tpope/vim-obsession'
"Use Vim in the browser
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
"****************************************************************************
"" Editor (NORMAL MODE ONLY)
"****************************************************************************
" Comment out lines with gcc or gc in visual mode
Plug 'tpope/vim-commentary'
" Tag viewer for class and method definitions
Plug 'majutsushi/tagbar'
" Display thin vertical lines for indentations
Plug 'Yggdroot/indentLine'
" Repeat a plug-in command
Plug 'tpope/vim-repeat'
" Improved clipping of text
Plug 'svermeulen/vim-easyclip'
"Replace double quotes, single quotes, etc
Plug 'tpope/vim-surround'
"Split single line to multiline and visa versa
Plug 'AndrewRadev/splitjoin.vim'
"Word Motion
" Plug 'chaoren/vim-wordmotion'
"Resize Windows
Plug 'simeji/winresizer'
"****************************************************************************
"" Editor (INSERT MODE ONLY)
"****************************************************************************
"Autocomplete
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'ervandew/supertab'
"Snippets
Plug 'sirver/UltiSnips'
Plug 'honza/vim-snippets'
" Autocomplete brackets, quotes, etc.
Plug 'Raimondi/delimitMate'
"Markdown tables
Plug 'dhruvasagar/vim-table-mode'
"
"Pairs of handy bracket mappings
Plug 'tpope/vim-unimpaired'
"Horizontal navigation"
Plug 'unblevable/quick-scope'
"Automatic bullet and numbered lists
Plug 'dkarter/bullets.vim'
"Automatic newline and indentation between brackets
Plug 'jiangmiao/auto-pairs'
"Merge git conflicts
Plug 'christoomey/vim-conflicted'
"****************************************************************************
"" Editor (VISUAL MODE ONLY)
"****************************************************************************
"Select a ruby block in VISUAL mode
Plug 'nelstrom/vim-textobj-rubyblock'
" dependency of vim-textobj-rubyblock
Plug 'kana/vim-textobj-user'
"Scratch buffer
" Plug 'mtth/scratch.vim'
"****************************************************************************
"" Editor (COMBINED MODES)
"****************************************************************************
"Make Goyo even nicer
Plug 'amix/vim-zenroom2'
"Code linting
Plug 'dense-analysis/ale'
Plug 'prettier/vim-prettier'
"OrgMode for VIM
Plug 'jceb/vim-orgmode'
"Atomesque coloures
Plug 'joshdick/onedark.vim'
"Distraction-free editing
Plug 'junegunn/goyo.vim'
"Markdown preview
" Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
" Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
" Plug 'iamcco/markdown-preview.nvim'
Plug 'suan/vim-instant-markdown', {'for': 'markdown', 'do': 'yarn install'}
"Floating Terminal
Plug 'voldikss/vim-floaterm'
"Cucumber syntax highlighting
Plug 'barboza/vim-cucumber-string-highlight'
""****************************************************************************
"" Version Control
"****************************************************************************
" Git wrapper
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb' " required by fugitive to :Gbrowse
" GraphQL syntax highlighting
Plug 'jparise/vim-graphql'
"***************************************************************************
"" Ruby and Rails
"***************************************************************************
"Refactor
Plug 'ecomba/vim-ruby-refactoring'
Plug 'thoughtbot/vim-rspec'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-cucumber'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-rake'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-rbenv'
Plug 'thoughtbot/vim-rspec'
Plug 'vim-ruby/vim-ruby'
"Ruby/Rails/RSpec documentation
" Plug 'lucapette/vim-ruby-doc'
" Toggle Ruby do/end and {}
Plug 'jgdavey/vim-blockle'
"***************************************************************************
"" Other Languages
"***************************************************************************
" go
"" Go Lang Bundle
Plug 'fatih/vim-go', {'do': ':GoInstallBinaries'}
" haskell
"" Haskell Bundle
Plug 'eagletmt/neco-ghc'
Plug 'dag/vim2hs'
Plug 'pbrisbin/vim-syntax-shakespeare'
" html
"" HTML Bundle
Plug 'hail2u/vim-css3-syntax'
" Plug 'gorodinskiy/vim-coloresque'
Plug 'tpope/vim-haml'
Plug 'mattn/emmet-vim'
Plug 'zeekay/vim-beautify'
" javascript
"" Javascript Bundle
Plug 'jelera/vim-javascript-syntax'
" lisp
"" Lisp Bundle
Plug 'vim-scripts/slimv.vim'
" python
"" Python Bundle
Plug 'davidhalter/jedi-vim'
Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'}
" typescript
Plug 'leafgarland/typescript-vim'
Plug 'HerringtonDarkholme/yats.vim'
"VimBeGood (Primeagen)
" Plug 'ThePrimeagen/vim-be-good', {'do': './install.sh'}
"FISH Scripting
Plug 'dag/vim-fish'
"Writing Tools
Plug 'preservim/vim-pencil'
Plug 'dbmrq/vim-ditto'
Plug 'honza/writer.vim'
Plug 'mattn/vim-metarw-gdrive'
Plug 'vimwiki/vimwiki'
"*****************************************************************************
call plug#end()
"***************************************************************************
"" Core VIM Keybindings
"***************************************************************************"
" Map leader to ,
let mapleader=','
"map LocalLeader to \\
let maplocalleader = "\\"
"Left (h) => [h]
noremap h h
"Up (j) => [t]
noremap t gj
"Down (k) => [n]
noremap n gk
"Right (l) => [s]
noremap s l
"End of line ($) => [-]
noremap - $
"Start of line (^) => [_]
noremap _ ^
"Jump to letter before (t) => [j]
noremap k t
"Sentences
noremap $ s
"m is shadowed by easyclip plugin
noremap gm m
" j/J moves between search mappings
nnoremap j n
nnoremap J N
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
" nnoremap j nzzzv
" nnoremap J Nzzzv
"Move text down
nnoremap <A-t> :m .+1<CR>==
inoremap <A-t> <Esc>:m .+1<CR>==gi
vnoremap <A-t> :m '>+1<CR>gv=gv
"Move text up
nnoremap <A-n> :m .-2<CR>==
inoremap <A-n> <Esc>:m .-2<CR>==gi
vnoremap <A-n> :m '<-2<CR>gv=gv
"*****************************************************************************
"" Mappings
"*****************************************************************************
"" Split
noremap <Leader>h :<C-u>split<CR>
" New buffer rather than the current file
noremap <Leader>v :<C-u>vnew<CR>
" Current file rather than a new buffer
" noremap <Leader>v :<C-u>vsplit<CR>
"*****************************************************************************
"Customised VIM
"*****************************************************************************
"Show how many lines yanked, inter alia
set report=0
"Hybrid line numbers
:set number relativenumber
:augroup numbertoggle
: autocmd!
: autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
: autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
:augroup END
"More natural movement in INSERT mode
behave mswin
"*****************************************************************************
"" Custom Bindings
"*****************************************************************************
"Fix indentation for the whole file
nnoremap <F7> gg=G<C-o><C-o>
" Bind F8 to fixing problems with ALE
nmap <F8> <Plug>(ale_fix)
"Force filetype 'yaml' for yml files
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml foldmethod=manual
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" autocmd BufNewFile,BufRead *.yml set ft=yaml
"Stop line wrap from breaking words
set linebreak
"Skip out of brackets
inoremap <C-e> <C-o>A
"Replace all
nnoremap S :%s///g<Left><Left><Left>
"Jump to next occurrence in INSERT mode
imap <C-j> <Esc>jcaw
"Replace all within a visual selection
" vnoremap S :s/\%V//g<Left><Left><Left>
"Ctrl-A for select all
" vnnoremap <C-a> ggVG
"Replace all matching strings in visual selection
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
" Close all hidden buffers
nnoremap <silent> <C-q> :Bdelete menu<CR>
function! ALEFixFast()
syntax off
exec "ALEFix"
syntax on
endfunction
"Save file, even if no changes
nor <silent> <Leader>w :w<CR>
vnoremap <silent> <C-w> <C-C>:update<CR>
"Close all buffers and quit Neovim
noremap <Leader>' :qall<CR>
"*****************************************************************************
"" Abbreviations
"*****************************************************************************
"" no one is really happy until you have this shortcuts
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall
"*****************************************************************************
"" ALE
"*****************************************************************************
" LINTERS
let g:ale_linters = {
\ 'gql': ['prettier'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\ 'vim': ['vint'],
\}
function! SettingsTurnOff()
"Turns syntax off only in current buffer
exec "syntax clear"
" exec "set nocursorcolumn"
" exec "set nocursorline"
" exec "set norelativenumber"
endfunction
function! SettingsTurnOn()
exec "syntax on"
" exec "set number relativenumber"
exec "AirlineRefresh"
endfunction
augroup YourGroup
autocmd!
autocmd User ALEFixPre call SettingsTurnOff()
autocmd User ALEFixPost call SettingsTurnOn()
augroup END
" FIXERS
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\}
let g:ale_lint_on_enter = 1
let g:ale_completion_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %(code): %%s [%severity%]'
let g:airline#extensions#ale#enabled = 1
" let g:ale_ruby_rubocop_executable = 'rubocop-daemon exec -- --auto-correct'
" set omnifunc=ale#completion#OmniFunc
"*****************************************************************************
"" Autocmd Rules, Functions
"*****************************************************************************
"" Functions
if !exists('*s:setupWrapping')
function s:setupWrapping()
set wrap
set wm=2
set textwidth=80
endfunction
endif
"*****************************************************************************
"" Autocmd Rules
"*****************************************************************************
"" The PC is fast enough, do syntax highlight syncing from start unless 200 lines
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=200
augroup END
"" Remember cursor position
augroup vimrc-remember-cursor-position
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
"" txt
augroup vimrc-wrapping
autocmd!
autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
augroup END
"" make/cmake
augroup vimrc-make-cmake
autocmd!
autocmd FileType make setlocal noexpandtab
autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
augroup END
set autoread
"*****************************************************************************
"" AUTO PAIRS
"*****************************************************************************
" Jump outside '"({
if !exists('g:AutoPairsShortcutJump')
let g:AutoPairsShortcutJump = '<C-l>'
endif
"*****************************************************************************
"" Buffers, Tabs, Windows
"*****************************************************************************
"" Buffer nav
noremap <leader>x :bn<CR>
"" Close buffer
noremap <leader>c :bd<CR>
"" Enable hidden buffers
" set hidden
"" Switching windows
noremap <C-h> <C-w>h
noremap <C-t> <C-w>j
noremap <C-n> <C-w>k
noremap <C-s> <C-w>l
"" Tabs
nnoremap <Tab> gt
nnoremap <S-Tab> gT
nnoremap <silent> <S-t> :tabnew<CR>
"Scratch buffer
function! Scratch()
tabnew
noswapfile hide enew
setlocal buftype=nofile
setlocal bufhidden=hide
"setlocal nobuflisted
"lcd ~
file scratch
endfunction
"*****************************************************************************
"" COC
"*****************************************************************************
" 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
" let g:coc_global_extensions = ['coc-solargraph']
"*****************************************************************************
"" Copy/Paste/Cut
"*****************************************************************************
if has('unnamedplus')
set clipboard=unnamed,unnamedplus
endif
noremap YY "+y<CR>
noremap <leader>p "+gP<CR>
noremap XX "+x<CR>
if has('macunix')
" pbcopy for OSX copy/paste
vmap <C-x> :!pbcopy<CR>
vmap <C-c> :w !pbcopy<CR><CR>
endif
"*****************************************************************************
"" deoplete
"*****************************************************************************
""deoplete
let g:deoplete#enable_at_startup = 1
let g:auto_complete_popup = "manual"
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ deoplete#mappings#manual_complete()
function! s:check_back_space() abort "{{{
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction"}}}
"*****************************************************************************
"" neosnippet
"*****************************************************************************
" " Plugin key-mappings.
" " Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <C-k> <Plug>(neosnippet_expand_or_jump)
" smap <C-k> <Plug>(neosnippet_expand_or_jump)
" xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
" if has('conceal')
" set conceallevel=2 concealcursor=niv
" endif
" " To use Honza's Vim Snippets
" let g:neosnippet#snippets_directory='~/.config/nvim/plugged/vim-snippets/snippets'
"*****************************************************************************
"" Encoding
"*****************************************************************************
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
let g:far#enable_undo=1
"*****************************************************************************
"" fish
"*****************************************************************************
if &shell =~# 'fish$'
set shell=sh
endif
"*****************************************************************************
"" fzf
"*****************************************************************************
set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
let $FZF_DEFAULT_COMMAND = "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'dist/**' -prune -o -type f -print -o -type l -print 2> /dev/null"
" nnoremap <silent> <leader>b :Buffers<CR>
nnoremap <silent> <leader>e :FZF -m<CR>
"Recovery commands from history through FZF
nmap <leader>y :History:<CR>
"NOTE: To open a file in a new tab CTRL-V, CTRL-X, or CTRL-T
"*****************************************************************************
"" General Settings
"*****************************************************************************
"Use `onedark` colour scheme
" colorscheme onedark
colo onedark
"Syntax highlighting from start unless 1000 lines (instead of 200)
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=1000
augroup END
"Refresh file when changed on disk
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI *
\ if mode() !~ '\v(c|r.?|!|t)' && getcmdwintype() == '' | checktime | endif
"Autowrite
set autowriteall
" :set tabstop=2
" :set shiftwidth=2
" :set expandtab
" Folding
set fdm=syntax
set nofoldenable
" set foldlevel=0
" Built-in Neovim autocomplete
cnoremap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
"NERDTree can modify files
set modifiable
"Add Cucumber filetype detection
au BufRead,BufNewFile *.cucumber set filetype=cucumber
"Various completion plugins require this
filetype plugin on
"Omni completion
" set omnifunc=syntaxcomplete#Complete
"Spell check
nnoremap <F10> :set spell! spelllang=en_gb,lt,fr,he!<CR>
"Center screen when going into INSERT mode
" autocmd InsertEnter * norm zz
"Thin line cursor in INSERT mode
highlight Cursor guifg=white guibg=black
highlight iCursor guifg=white guibg=steelblue
set guicursor=n-v-c:block-Cursor
set guicursor=i:ver25-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait10
"Highlight current line
autocmd InsertEnter,InsertLeave * set cul!
"Auotmatically split to the right
set splitright
"*****************************************************************************
"" Git
"*****************************************************************************
noremap <Leader>ga :Gwrite<CR>
noremap <Leader>gc :Gcommit<CR>
noremap <Leader>gsh :Gpush<CR>
noremap <Leader>gll :Gpull<CR>
noremap <Leader>gs :Gstatus<CR>
noremap <Leader>gb :Gblame<CR>
noremap <Leader>gd :Gvdiff<CR>
noremap <Leader>gr :Gremove<CR>
"" Open current line on GitHub
nnoremap <Leader>o :.Gbrowse<CR>
set diffopt+=vertical
"*****************************************************************************
"" Go Language
"*****************************************************************************
" autocmd BufWritePost *.go !go test
"*****************************************************************************
"" grep.vim
"*****************************************************************************
" grep.vim
nnoremap <silent> <leader>f :Rgrep<CR>
let Grep_Default_Options = '-IR'
let Grep_Skip_Files = '*.log *.db'
let Grep_Skip_Dirs = '.git node_modules'
"*****************************************************************************
"" HTML
"*****************************************************************************
" for html files, 2 spaces
autocmd Filetype html setlocal ts=2 sw=2 expandtab
"View HTML Text
function! ViewHtmlText(url)
if !empty(a:url)
new
setlocal buftype=nofile bufhidden=hide noswapfile
execute 'r !elinks ' . a:url . ' -dump -dump-width ' . winwidth(0)
1d
endif
endfunction
" Save and view text for current html file.
nnoremap <Leader>H :update<Bar>call ViewHtmlText(expand('%:p'))<CR>
" " View text for visually selected url.
vnoremap <Leader>h y:call ViewHtmlText(@*)<CR>
" View text for URL from clipboard.
" On Linux, use @* for current selection or @+ for text in clipboard.
nnoremap <Leader>h :call ViewHtmlText(@+)<CR>
"*****************************************************************************
"" Emmet
"*****************************************************************************
" let g:user_emmet_install_global = 0
" autocmd FileType html,css,erb EmmetInstall
let g:user_emmet_leader_key=','
"*****************************************************************************
"" Indentations, Tabs, Whitespaces
"*****************************************************************************
"" Fix backspace indent
set backspace=indent,eol,start
"" Tabs. May be overridden by autocmd rules
set tabstop=2
set softtabstop=0
set shiftwidth=2
set expandtab
" remove trailing whitespaces
command! FixWhitespace :%s/\s\+$//e
"Fix indentation for the whole file
" nnoremap <F7> gg=G<C-o><C-o>
"*****************************************************************************
"" JavaScript
"*****************************************************************************
" javascript
let g:javascript_enable_domhtmlcss = 1
" vim-javascript
augroup vimrc-javascript
autocmd!
autocmd FileType javascript setl tabstop=4|setl shiftwidth=4|setl expandtab softtabstop=4
augroup END
"*****************************************************************************
"" LanguageClient-Neovim
"*****************************************************************************
" Tell the language client to use the default IP and port
" that Solargraph runs on
" let g:LanguageClient_serverCommands = {
" \ 'ruby': ['tcp://localhost:7658']
" \ }
" Don't send a stop signal to the server when exiting vim.
" This is optional, but I don't like having to restart Solargraph
" every time I restart vim.
" let g:LanguageClient_autoStop = 0
" Configure ruby omni-completion to use the language client:
" autocmd FileType ruby setlocal omnifunc=LanguageClient#complete
" Required for operations modifying multiple buffers like rename.
" set hidden
" let g:LanguageClient_serverCommands = {
" \ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
" \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
" \ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
" \ 'python': ['/usr/local/bin/pyls'],
" \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'],
" \ }
" nnoremap <F5> :call LanguageClient_contextMenu()<CR>
" " Or map each action separately
" nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
" nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
" nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
"*****************************************************************************
"" Macros
"*****************************************************************************
nnoremap <leader>gcr If<esc>A # rubocop:disable RSpec/Focus<esc>
nnoremap <leader>sal gg<esc>O$seeds_already_loaded = true<esc><C-o>
nnoremap <leader>gms gg<esc>O$minimal_seeds = true<esc><C-o>
"*****************************************************************************
"" Markdown
"*****************************************************************************
"Markdown plugin
" filetype plugin on
let g:vim_markdown_conceal = 0
let g:vim_markdown_conceal_code_blocks = 0
"Uncomment to override defaults:
"let g:instant_markdown_slow = 1
"let g:instant_markdown_autostart = 0
"let g:instant_markdown_open_to_the_world = 1
"let g:instant_markdown_allow_unsafe_content = 1
"let g:instant_markdown_allow_external_content = 0
"let g:instant_markdown_mathjax = 1
"let g:instant_markdown_logfile = '/tmp/instant_markdown.log'
"let g:instant_markdown_autoscroll = 0
"let g:instant_markdown_port = 8888
"let g:instant_markdown_python = 1
"MarkdownPreview
" set to 1, nvim will open the preview window after entering the markdown buffer
" default: 0
let g:mkdp_auto_start = 1
" set to 1, the nvim will auto close current preview window when change
" from markdown buffer to another buffer
" default: 1
let g:mkdp_auto_close = 1
" set to 1, the vim will refresh markdown when save the buffer or
" leave from insert mode, default 0 is auto refresh markdown as you edit or
" move the cursor
" default: 0
let g:mkdp_refresh_slow = 0
" set to 1, the MarkdownPreview command can be use for all files,
" by default it can be use in markdown file
" default: 0
let g:mkdp_command_for_global = 0
" set to 1, preview server available to others in your network
" by default, the server listens on localhost (127.0.0.1)
" default: 0
let g:mkdp_open_to_the_world = 0
" use custom IP to open preview page
" useful when you work in remote vim and preview on local browser
" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9
" default empty
let g:mkdp_open_ip = ''
" specify browser to open preview page
" default: ''
let g:mkdp_browser = ''
" set to 1, echo preview page url in command line when open preview page
" default is 0
let g:mkdp_echo_preview_url = 0
" a custom vim function name to open preview page
" this function will receive url as param
" default is empty
let g:mkdp_browserfunc = ''
" options for markdown render
" mkit: markdown-it options for render
" katex: katex options for math
" uml: markdown-it-plantuml options
" maid: mermaid options
" disable_sync_scroll: if disable sync scroll, default 0
" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle'
" middle: mean the cursor position alway show at the middle of the preview page
" top: mean the vim top viewport alway show at the top of the preview page
" relative: mean the cursor position alway show at the relative positon of the preview page
" hide_yaml_meta: if hide yaml metadata, default is 1
" sequence_diagrams: js-sequence-diagrams options
" content_editable: if enable content editable for preview page, default: v:false
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1,
\ 'sequence_diagrams': {},
\ 'flowchart_diagrams': {},
\ 'content_editable': v:false
\ }
" use a custom markdown style must be absolute path
" like '/Users/username/markdown.css' or expand('~/markdown.css')
let g:mkdp_markdown_css = ''
" use a custom highlight style must absolute path
" like '/Users/username/highlight.css' or expand('~/highlight.css')
let g:mkdp_highlight_css = ''
" use a custom port to start server or random for empty
let g:mkdp_port = ''
" preview page title
" ${name} will be replace with the file name
let g:mkdp_page_title = '「${name}」'
"*****************************************************************************
"" NERDTree
"*****************************************************************************
"" NERDTree configuration
let g:NERDTreeChDirMode=2
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let g:NERDTreeShowBookmarks=1
let g:nerdtree_tabs_focus_on_files=1
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
let g:NERDTreeWinSize = 50
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
nnoremap <silent> <F2> :NERDTreeFind<CR>
nnoremap <silent> <F3> :NERDTreeToggle<CR>
let g:NERDTreeMapOpenInTab = "l"
"Close NERDTree when you open a file
let NERDTreeQuitOnOpen = 1
"Prettify NERDTree
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
" autocmd FileType nerdtree setlocal noreadonly
"*****************************************************************************
"" polyglot
"*****************************************************************************
" Syntax highlight
" Default highlight is better than polyglot
let g:polyglot_disabled = ['python']
let python_highlight_all = 1
"*****************************************************************************
"" Python
"*****************************************************************************
" vim-python
augroup vimrc-python
autocmd!
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 colorcolumn=79
\ formatoptions+=croq softtabstop=4
\ cinwords=if,elif,else,for,while,try,except,finally,def,class,with
augroup END
"*****************************************************************************
"" jedi-vim
"*****************************************************************************
let g:jedi#popup_on_dot = 0
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_definitions_command = "<leader>d"
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#rename_command = "<leader>r"
let g:jedi#show_call_signatures = "0"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#smart_auto_mappings = 0
"*****************************************************************************
"" ripgrep
"*****************************************************************************
if executable('rg')
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
set grepprg=rg\ --vimgrep
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
endif
"*****************************************************************************
"" rspec.vim
"*****************************************************************************
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
"Prepend `bundle exec`
let g:rspec_command = "!bundle exec rspec {spec}"
"*****************************************************************************
"" Ruby
"*****************************************************************************
"Omnicomplete
let g:ruby_host_prog = '~/.rbenv/shims/neovim-ruby-host'
let g:ruby_path = system('echo $HOME/.rbenv/shims')
" ruby
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
augroup vimrc-ruby
autocmd!
autocmd BufNewFile,BufRead *.rb,*.rbw,*.gemspec setlocal filetype=ruby
autocmd FileType ruby set tabstop=2|set shiftwidth=2|set expandtab softtabstop=2
augroup END
" For ruby refactory
if has('nvim')
runtime! macros/matchit.vim
else
packadd! matchit
endif
" Ruby refactory
nnoremap <leader>rap :RAddParameter<cr>
nnoremap <leader>rcpc :RConvertPostConditional<cr>
nnoremap <leader>rel :RExtractLet<cr>
vnoremap <leader>rec :RExtractConstant<cr>
vnoremap <leader>relv :RExtractLocalVariable<cr>
nnoremap <leader>rit :RInlineTemp<cr>
vnoremap <leader>rrlv :RRenameLocalVariable<cr>
vnoremap <leader>rriv :RRenameInstanceVariable<cr>
vnoremap <leader>rem :RExtractMethod<cr>
"Run RSpec in Tmux
" map <Leader>rt :w<cr>:call RunCurrentTest('!ts be rspec')<CR>
" Thoughtbot Vim-RSpec
let g:rspec_command = "Dispatch bundle exec rspec {spec}"
" let g:rspec_command = "!bundle exec rspec {spec}"
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
" map <LocalLeader>s :e db/schema.rb<CR>
"*****************************************************************************
"" Search
"*****************************************************************************
"" Clean search (highlight)
nnoremap <silent> <leader><space> :noh<cr>
"" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
set fileformats=unix,dos,mac
if exists('$SHELL')
set shell=$SHELL
else
set shell=/bin/sh
endif
"Search for visually selected text
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
"*****************************************************************************
"" Session Management
"*****************************************************************************
nnoremap <leader>so :OpenSession<Space>
nnoremap <leader>ss :SaveSession<Space>
nnoremap <leader>sd :DeleteSession<CR>
nnoremap <leader>sc :CloseSession<CR>
let g:session_directory = "~/.config/nvim/session"
let g:session_autoload = "prompt"
let g:session_autosave = "yes"
let g:session_autosave_periodic = 1
let g:session_command_aliases = 1
let g:session_autosave_silent = 1
"*****************************************************************************
"" The Silver Searcher
"*****************************************************************************
if executable('ag')
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
set grepprg=ag\ --nogroup\ --nocolor
endif
let g:startify_session_dir = '~/.config/nvim/session'
let g:startify_lists = [
\ { 'type': 'files', 'header': [' Files'] },
\ { 'type': 'dir', 'header': [' Current Directory '. getcwd()] },
\ { 'type': 'sessions', 'header': [' Sessions'] },
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
\ ]
let g:startify_bookmarks = [
\ { 'i': '~/.config/nvim/init.vim' },
\ '~/Development/inspiregroup/chameleon/creator/services/creator-backend',
\ '~/Development/publish/clockworkpc.github.io',
\ '~/Development/inspiregroup/chameleon/collect',
\ ]
let g:startify_session_autoload = 1
let g:startify_fortune_use_unicode = 1
let g:startify_session_persistence = 1
let g:startify_enable_special = 0
"*****************************************************************************
"" Tagbar
"*****************************************************************************
nmap <silent> <F4> :TagbarToggle<CR>
let g:tagbar_autofocus = 1
let g:tagbar_type_ruby = {
\ 'kinds' : [
\ 'm:modules',
\ 'c:classes',
\ 'd:describes',
\ 'C:contexts',
\ 'f:methods',
\ 'F:singleton methods'
\ ]
\ }
"*****************************************************************************
"" Terminal Emulation
"*****************************************************************************
" terminal emulation
nnoremap <silent> <leader>sh :terminal<CR>
"Open a terminal in a new tab
map <silent> <M-C-N> :tabnew <bar> :terminal<CR>
"*****************************************************************************
"" textobj-rubyblock
"*****************************************************************************
runtime macros/matchit.vim
set nocompatible
if has("autocmd")
filetype indent plugin on
endif
let g:textobj_ruby_more_mappings = 1
"*****************************************************************************
"" Typescript
"*****************************************************************************
" typescript
let g:yats_host_keyword = 1
"*****************************************************************************
"" UltiSnips
"*****************************************************************************
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
" let g:UltiSnipsExpandTrigger="<tab>"
" let g:UltiSnipsJumpForwardTrigger="<c-b>"
" let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" let g:UltiSnipsEditSplit="vertical"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
let g:UltiSnipsEditSplit="vertical"
" let g:UltiSnipsSnippetDirectories=["UltiSnips", "myUltiSnips"]
"*****************************************************************************
"" vim-airline
"*****************************************************************************
let g:airline_theme = 'powerlineish'
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline#extensions#tagbar#enabled = 1
let g:airline_skip_empty_sections = 1
"python
let g:airline#extensions#virtualenv#enabled = 1
"*****************************************************************************
"" Vimroom
"*****************************************************************************
"Vimroom
let g:goyo_width=100
let g:goyo_margin_top = 2
let g:goyo_margin_bottom = 2
nnoremap <silent> <leader>z :Goyo<cr>
"*****************************************************************************
"" vim-ruby-doc
"*****************************************************************************
" For some reason this plugin doesn't work anymore,
" so I hacked together the same functionality, using its example.
" Replace 'firefox' with whatever command you need instead.
let g:ruby_doc_url_template="http://rubydoc.info/search/stdlib/core?q=%"
let g:rails_doc_url_template="http://api.rubyonrails.org/?q=%"
let g:rspec_doc_url_template='https://www.relishapp.com/rspec/search?query=%'
function! AnyRDoc(url_template)
if &ft =~ "ruby"
else
return
endif
let s:wordUnderCursor = expand("<cword>")
let s:url = substitute(a:url_template, "%", s:wordUnderCursor, "g")
let s:cmd = "!firefox \"" . s:url . "\""
execute s:cmd
endfunction
map RB :call AnyRDoc(ruby_doc_url_template)<CR>
map RR :call AnyRDoc(rails_doc_url_template)<CR>
map RS :call AnyRDoc(rspec_doc_url_template)<CR>
"*****************************************************************************
"" visualbell
"*****************************************************************************
" Disable visualbell
set noerrorbells visualbell t_vb=
if has('autocmd')
autocmd GUIEnter * set visualbell t_vb=
endif
"*****************************************************************************
"" Visual Mode
"*****************************************************************************
"" Vmap for maintain Visual Mode after shifting > and <
vmap < <gv
vmap > >gv
"" Move visual block
" vnoremap J :m '>+1<CR>gv=gv
" vnoremap K :m '<-2<CR>gv=gv
"*****************************************************************************
"" Visual Settings
"*****************************************************************************
syntax on
set ruler
set number
let no_buffers_menu=1
set mousemodel=popup
set t_Co=256
set guioptions=egmrti
set gfn=Monospace\ 10
if has("gui_running")
if has("gui_mac") || has("gui_macvim")
set guifont=Menlo:h12
set transparency=7
endif
else
let g:CSApprox_loaded = 1
" IndentLine
let g:indentLine_enabled = 1
let g:indentLine_concealcursor = 0
let g:indentLine_char = '┆'
let g:indentLine_faster = 1
endif
"" Disable the blinking cursor.
set gcr+=a:blinkon0
set scrolloff=3
"" Status bar
set laststatus=2
"" Use modeline overrides
set modeline
set modelines=10
set title
set titleold="Terminal"
set titlestring=%F
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
if exists("*fugitive#statusline")
set statusline+=%{fugitive#statusline()}
endif
"*****************************************************************************
"" XML
"*****************************************************************************
function! DoFormatXML()
:%s/></>\r</g
:0
=:$
endfunction
com! FormatXML call DoFormatXML()
"*****************************************************************************
"" YAML
"*****************************************************************************
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
set foldlevelstart=20
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'
" let g:ale_lint_on_text_changed = 'never'
"*****************************************************************************
"" CPC NEOVIM CONFIGURATION
"" Maintainer: Alexander JK Garber
"*****************************************************************************
"*****************************************************************************
"" Vim-PLug core
"*****************************************************************************
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
let g:vim_bootstrap_langs = "go,haskell,html,javascript,lisp,python,ruby,typescript"
let g:vim_bootstrap_editor = "nvim" " nvim or 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
" Required:
call plug#begin(expand('~/.config/nvim/plugged'))
"****************************************************************************
"" Project
"****************************************************************************
" Functional Start Screen
" Plug 'mhinz/vim-startify'
" Treeview file browser in VIM
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
" Plug 'MarSoft/nerdtree-grep-plugin'
" Status bar above and below
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Show changed lines in gutter
Plug 'airblade/vim-gitgutter'
" Search for strings in files
Plug 'vim-scripts/grep.vim'
"GVim-only colour schemes
Plug 'vim-scripts/CSApprox'
" Fuzzy file search
if isdirectory('/usr/local/opt/fzf')
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
else
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
endif
let g:make = 'gmake'
if exists('make')
let g:make = 'make'
endif
" Find and Replace
Plug 'brooth/far.vim'
" Interactive command execution
Plug 'Shougo/vimproc.vim', {'do': g:make}
"" Vim-Session
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'
" ctags
" Plug 'ludovicchabant/vim-gutentags'
" Plug 'craigemery/vim-autotag'
"codequery
" Plug 'Shougo/unite.vim'
" Plug 'devjoe/vim-codequery'
"grep replace
Plug 'skwp/greplace.vim'
"view images
Plug 'ashisha/image.vim'
"Reload files changed on disk
Plug 'djoshea/vim-autoread'
" Fountain plugin
Plug 'kblin/vim-fountain'
" Close buffers
Plug 'Asheq/close-buffers.vim'
" Conquer of Code (Autocomplete)
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Autosave sessions
Plug 'tpope/vim-obsession'
"Use Vim in the browser
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
"****************************************************************************
"" Editor (NORMAL MODE ONLY)
"****************************************************************************
" Comment out lines with gcc or gc in visual mode
Plug 'tpope/vim-commentary'
" Tag viewer for class and method definitions
Plug 'majutsushi/tagbar'
" Display thin vertical lines for indentations
Plug 'Yggdroot/indentLine'
" Repeat a plug-in command
Plug 'tpope/vim-repeat'
" Improved clipping of text
Plug 'svermeulen/vim-easyclip'
"Replace double quotes, single quotes, etc
Plug 'tpope/vim-surround'
"Split single line to multiline and visa versa
Plug 'AndrewRadev/splitjoin.vim'
"Word Motion
" Plug 'chaoren/vim-wordmotion'
"Resize Windows
Plug 'simeji/winresizer'
"****************************************************************************
"" Editor (INSERT MODE ONLY)
"****************************************************************************
"Autocomplete
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'ervandew/supertab'
"Snippets
Plug 'sirver/UltiSnips'
Plug 'honza/vim-snippets'
" Autocomplete brackets, quotes, etc.
Plug 'Raimondi/delimitMate'
"Markdown tables
Plug 'dhruvasagar/vim-table-mode'
"
"Pairs of handy bracket mappings
Plug 'tpope/vim-unimpaired'
"Horizontal navigation"
Plug 'unblevable/quick-scope'
"Automatic bullet and numbered lists
Plug 'dkarter/bullets.vim'
"Automatic newline and indentation between brackets
Plug 'jiangmiao/auto-pairs'
"Merge git conflicts
Plug 'christoomey/vim-conflicted'
"****************************************************************************
"" Editor (VISUAL MODE ONLY)
"****************************************************************************
"Select a ruby block in VISUAL mode
Plug 'nelstrom/vim-textobj-rubyblock'
" dependency of vim-textobj-rubyblock
Plug 'kana/vim-textobj-user'
"Scratch buffer
" Plug 'mtth/scratch.vim'
"****************************************************************************
"" Editor (COMBINED MODES)
"****************************************************************************
"Make Goyo even nicer
Plug 'amix/vim-zenroom2'
"Code linting
Plug 'dense-analysis/ale'
Plug 'prettier/vim-prettier'
"OrgMode for VIM
Plug 'jceb/vim-orgmode'
"Atomesque coloures
Plug 'joshdick/onedark.vim'
"Distraction-free editing
Plug 'junegunn/goyo.vim'
"Markdown preview
" Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
" Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
" Plug 'iamcco/markdown-preview.nvim'
Plug 'suan/vim-instant-markdown', {'for': 'markdown', 'do': 'yarn install'}
"Floating Terminal
Plug 'voldikss/vim-floaterm'
"Cucumber syntax highlighting
Plug 'barboza/vim-cucumber-string-highlight'
""****************************************************************************
"" Version Control
"****************************************************************************
" Git wrapper
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb' " required by fugitive to :Gbrowse
" GraphQL syntax highlighting
Plug 'jparise/vim-graphql'
"***************************************************************************
"" Ruby and Rails
"***************************************************************************
"Refactor
Plug 'ecomba/vim-ruby-refactoring'
Plug 'thoughtbot/vim-rspec'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-cucumber'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-rake'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-rbenv'
Plug 'thoughtbot/vim-rspec'
Plug 'vim-ruby/vim-ruby'
"Ruby/Rails/RSpec documentation
" Plug 'lucapette/vim-ruby-doc'
" Toggle Ruby do/end and {}
Plug 'jgdavey/vim-blockle'
"***************************************************************************
"" Other Languages
"***************************************************************************
" go
"" Go Lang Bundle
Plug 'fatih/vim-go', {'do': ':GoInstallBinaries'}
" haskell
"" Haskell Bundle
Plug 'eagletmt/neco-ghc'
Plug 'dag/vim2hs'
Plug 'pbrisbin/vim-syntax-shakespeare'
" html
"" HTML Bundle
Plug 'hail2u/vim-css3-syntax'
" Plug 'gorodinskiy/vim-coloresque'
Plug 'tpope/vim-haml'
Plug 'mattn/emmet-vim'
Plug 'zeekay/vim-beautify'
" javascript
"" Javascript Bundle
Plug 'jelera/vim-javascript-syntax'
" lisp
"" Lisp Bundle
Plug 'vim-scripts/slimv.vim'
" python
"" Python Bundle
Plug 'davidhalter/jedi-vim'
Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'}
" typescript
Plug 'leafgarland/typescript-vim'
Plug 'HerringtonDarkholme/yats.vim'
"VimBeGood (Primeagen)
" Plug 'ThePrimeagen/vim-be-good', {'do': './install.sh'}
"FISH Scripting
Plug 'dag/vim-fish'
"Writing Tools
Plug 'preservim/vim-pencil'
Plug 'dbmrq/vim-ditto'
Plug 'honza/writer.vim'
Plug 'mattn/vim-metarw-gdrive'
Plug 'vimwiki/vimwiki'
"*****************************************************************************
call plug#end()
"***************************************************************************
"" Core VIM Keybindings
"***************************************************************************"
" Map leader to ,
let mapleader=','
"map LocalLeader to \\
let maplocalleader = "\\"
"Left (h) => [h]
noremap h h
"Up (j) => [t]
noremap t gj
"Down (k) => [n]
noremap n gk
"Right (l) => [s]
noremap s l
"End of line ($) => [-]
noremap - $
"Start of line (^) => [_]
noremap _ ^
"Jump to letter before (t) => [j]
noremap k t
"Sentences
noremap $ s
"m is shadowed by easyclip plugin
noremap gm m
" j/J moves between search mappings
nnoremap j n
nnoremap J N
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
" nnoremap j nzzzv
" nnoremap J Nzzzv
"Move text down
nnoremap <A-t> :m .+1<CR>==
inoremap <A-t> <Esc>:m .+1<CR>==gi
vnoremap <A-t> :m '>+1<CR>gv=gv
"Move text up
nnoremap <A-n> :m .-2<CR>==
inoremap <A-n> <Esc>:m .-2<CR>==gi
vnoremap <A-n> :m '<-2<CR>gv=gv
"*****************************************************************************
"" Mappings
"*****************************************************************************
"" Split
noremap <Leader>h :<C-u>split<CR>
" New buffer rather than the current file
noremap <Leader>v :<C-u>vnew<CR>
" Current file rather than a new buffer
" noremap <Leader>v :<C-u>vsplit<CR>
"*****************************************************************************
"Customised VIM
"*****************************************************************************
"Show how many lines yanked, inter alia
set report=0
"Hybrid line numbers
:set number relativenumber
:augroup numbertoggle
: autocmd!
: autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
: autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
:augroup END
"More natural movement in INSERT mode
behave mswin
"*****************************************************************************
"" Custom Bindings
"*****************************************************************************
"Fix indentation for the whole file
nnoremap <F7> gg=G<C-o><C-o>
" Bind F8 to fixing problems with ALE
nmap <F8> <Plug>(ale_fix)
"Force filetype 'yaml' for yml files
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml foldmethod=manual
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" autocmd BufNewFile,BufRead *.yml set ft=yaml
"Stop line wrap from breaking words
set linebreak
"Skip out of brackets
inoremap <C-e> <C-o>A
"Replace all
nnoremap S :%s///g<Left><Left><Left>
"Jump to next occurrence in INSERT mode
imap <C-j> <Esc>jcaw
"Replace all within a visual selection
" vnoremap S :s/\%V//g<Left><Left><Left>
"Ctrl-A for select all
" vnnoremap <C-a> ggVG
"Replace all matching strings in visual selection
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
" Close all hidden buffers
nnoremap <silent> <C-q> :Bdelete menu<CR>
function! ALEFixFast()
syntax off
exec "ALEFix"
syntax on
endfunction
"Save file, even if no changes
nor <silent> <Leader>w :w<CR>
vnoremap <silent> <C-w> <C-C>:update<CR>
"Close all buffers and quit Neovim
noremap <Leader>' :qall<CR>
"*****************************************************************************
"" Abbreviations
"*****************************************************************************
"" no one is really happy until you have this shortcuts
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall
"*****************************************************************************
"" ALE
"*****************************************************************************
" LINTERS
let g:ale_linters = {
\ 'gql': ['prettier'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\ 'vim': ['vint'],
\}
function! SettingsTurnOff()
"Turns syntax off only in current buffer
exec "syntax clear"
" exec "set nocursorcolumn"
" exec "set nocursorline"
" exec "set norelativenumber"
endfunction
function! SettingsTurnOn()
exec "syntax on"
" exec "set number relativenumber"
exec "AirlineRefresh"
endfunction
augroup YourGroup
autocmd!
autocmd User ALEFixPre call SettingsTurnOff()
autocmd User ALEFixPost call SettingsTurnOn()
augroup END
" FIXERS
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\}
let g:ale_lint_on_enter = 1
let g:ale_completion_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %(code): %%s [%severity%]'
let g:airline#extensions#ale#enabled = 1
" let g:ale_ruby_rubocop_executable = 'rubocop-daemon exec -- --auto-correct'
" set omnifunc=ale#completion#OmniFunc
"*****************************************************************************
"" Autocmd Rules, Functions
"*****************************************************************************
"" Functions
if !exists('*s:setupWrapping')
function s:setupWrapping()
set wrap
set wm=2
set textwidth=80
endfunction
endif
"*****************************************************************************
"" Autocmd Rules
"*****************************************************************************
"" The PC is fast enough, do syntax highlight syncing from start unless 200 lines
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=200
augroup END
"" Remember cursor position
augroup vimrc-remember-cursor-position
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
"" txt
augroup vimrc-wrapping
autocmd!
autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
augroup END
"" make/cmake
augroup vimrc-make-cmake
autocmd!
autocmd FileType make setlocal noexpandtab
autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
augroup END
set autoread
"*****************************************************************************
"" AUTO PAIRS
"*****************************************************************************
" Jump outside '"({
if !exists('g:AutoPairsShortcutJump')
let g:AutoPairsShortcutJump = '<C-l>'
endif
"*****************************************************************************
"" Buffers, Tabs, Windows
"*****************************************************************************
"" Buffer nav
noremap <leader>x :bn<CR>
"" Close buffer
noremap <leader>c :bd<CR>
"" Enable hidden buffers
" set hidden
"" Switching windows
noremap <C-h> <C-w>h
noremap <C-t> <C-w>j
noremap <C-n> <C-w>k
noremap <C-s> <C-w>l
"" Tabs
nnoremap <Tab> gt
nnoremap <S-Tab> gT
nnoremap <silent> <S-t> :tabnew<CR>
"Scratch buffer
function! Scratch()
tabnew
noswapfile hide enew
setlocal buftype=nofile
setlocal bufhidden=hide
"setlocal nobuflisted
"lcd ~
file scratch
endfunction
"*****************************************************************************
"" COC
"*****************************************************************************
" 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
" let g:coc_global_extensions = ['coc-solargraph']
"*****************************************************************************
"" Copy/Paste/Cut
"*****************************************************************************
if has('unnamedplus')
set clipboard=unnamed,unnamedplus
endif
noremap YY "+y<CR>
noremap <leader>p "+gP<CR>
noremap XX "+x<CR>
if has('macunix')
" pbcopy for OSX copy/paste
vmap <C-x> :!pbcopy<CR>
vmap <C-c> :w !pbcopy<CR><CR>
endif
"*****************************************************************************
"" deoplete
"*****************************************************************************
""deoplete
let g:deoplete#enable_at_startup = 1
let g:auto_complete_popup = "manual"
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ deoplete#mappings#manual_complete()
function! s:check_back_space() abort "{{{
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction"}}}
"*****************************************************************************
"" neosnippet
"*****************************************************************************
" " Plugin key-mappings.
" " Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <C-k> <Plug>(neosnippet_expand_or_jump)
" smap <C-k> <Plug>(neosnippet_expand_or_jump)
" xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
" if has('conceal')
" set conceallevel=2 concealcursor=niv
" endif
" " To use Honza's Vim Snippets
" let g:neosnippet#snippets_directory='~/.config/nvim/plugged/vim-snippets/snippets'
"*****************************************************************************
"" Encoding
"*****************************************************************************
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
let g:far#enable_undo=1
"*****************************************************************************
"" fish
"*****************************************************************************
if &shell =~# 'fish$'
set shell=sh
endif
"*****************************************************************************
"" fzf
"*****************************************************************************
set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
let $FZF_DEFAULT_COMMAND = "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'dist/**' -prune -o -type f -print -o -type l -print 2> /dev/null"
" nnoremap <silent> <leader>b :Buffers<CR>
nnoremap <silent> <leader>e :FZF -m<CR>
"Recovery commands from history through FZF
nmap <leader>y :History:<CR>
"NOTE: To open a file in a new tab CTRL-V, CTRL-X, or CTRL-T
"*****************************************************************************
"" General Settings
"*****************************************************************************
"Use `onedark` colour scheme
" colorscheme onedark
colo onedark
"Syntax highlighting from start unless 1000 lines (instead of 200)
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=1000
augroup END
"Refresh file when changed on disk
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI *
\ if mode() !~ '\v(c|r.?|!|t)' && getcmdwintype() == '' | checktime | endif
"Autowrite
set autowriteall
" :set tabstop=2
" :set shiftwidth=2
" :set expandtab
" Folding
set fdm=syntax
set nofoldenable
" set foldlevel=0
" Built-in Neovim autocomplete
cnoremap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
"NERDTree can modify files
set modifiable
"Add Cucumber filetype detection
au BufRead,BufNewFile *.cucumber set filetype=cucumber
"Various completion plugins require this
filetype plugin on
"Omni completion
" set omnifunc=syntaxcomplete#Complete
"Spell check
nnoremap <F10> :set spell! spelllang=en_gb,lt,fr,he!<CR>
"Center screen when going into INSERT mode
" autocmd InsertEnter * norm zz
"Thin line cursor in INSERT mode
highlight Cursor guifg=white guibg=black
highlight iCursor guifg=white guibg=steelblue
set guicursor=n-v-c:block-Cursor
set guicursor=i:ver25-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait10
"Highlight current line
autocmd InsertEnter,InsertLeave * set cul!
"Auotmatically split to the right
set splitright
"*****************************************************************************
"" Git
"*****************************************************************************
noremap <Leader>ga :Gwrite<CR>
noremap <Leader>gc :Gcommit<CR>
noremap <Leader>gsh :Gpush<CR>
noremap <Leader>gll :Gpull<CR>
noremap <Leader>gs :Gstatus<CR>
noremap <Leader>gb :Gblame<CR>
noremap <Leader>gd :Gvdiff<CR>
noremap <Leader>gr :Gremove<CR>
"" Open current line on GitHub
nnoremap <Leader>o :.Gbrowse<CR>
set diffopt+=vertical
"*****************************************************************************
"" Go Language
"*****************************************************************************
" autocmd BufWritePost *.go !go test
"*****************************************************************************
"" grep.vim
"*****************************************************************************
" grep.vim
nnoremap <silent> <leader>f :Rgrep<CR>
let Grep_Default_Options = '-IR'
let Grep_Skip_Files = '*.log *.db'
let Grep_Skip_Dirs = '.git node_modules'
"*****************************************************************************
"" HTML
"*****************************************************************************
" for html files, 2 spaces
autocmd Filetype html setlocal ts=2 sw=2 expandtab
"View HTML Text
function! ViewHtmlText(url)
if !empty(a:url)
new
setlocal buftype=nofile bufhidden=hide noswapfile
execute 'r !elinks ' . a:url . ' -dump -dump-width ' . winwidth(0)
1d
endif
endfunction
" Save and view text for current html file.
nnoremap <Leader>H :update<Bar>call ViewHtmlText(expand('%:p'))<CR>
" " View text for visually selected url.
vnoremap <Leader>h y:call ViewHtmlText(@*)<CR>
" View text for URL from clipboard.
" On Linux, use @* for current selection or @+ for text in clipboard.
nnoremap <Leader>h :call ViewHtmlText(@+)<CR>
"*****************************************************************************
"" Emmet
"*****************************************************************************
" let g:user_emmet_install_global = 0
" autocmd FileType html,css,erb EmmetInstall
let g:user_emmet_leader_key=','
"*****************************************************************************
"" Indentations, Tabs, Whitespaces
"*****************************************************************************
"" Fix backspace indent
set backspace=indent,eol,start
"" Tabs. May be overridden by autocmd rules
set tabstop=2
set softtabstop=0
set shiftwidth=2
set expandtab
" remove trailing whitespaces
command! FixWhitespace :%s/\s\+$//e
"Fix indentation for the whole file
" nnoremap <F7> gg=G<C-o><C-o>
"*****************************************************************************
"" JavaScript
"*****************************************************************************
" javascript
let g:javascript_enable_domhtmlcss = 1
" vim-javascript
augroup vimrc-javascript
autocmd!
autocmd FileType javascript setl tabstop=4|setl shiftwidth=4|setl expandtab softtabstop=4
augroup END
"*****************************************************************************
"" LanguageClient-Neovim
"*****************************************************************************
" Tell the language client to use the default IP and port
" that Solargraph runs on
" let g:LanguageClient_serverCommands = {
" \ 'ruby': ['tcp://localhost:7658']
" \ }
" Don't send a stop signal to the server when exiting vim.
" This is optional, but I don't like having to restart Solargraph
" every time I restart vim.
" let g:LanguageClient_autoStop = 0
" Configure ruby omni-completion to use the language client:
" autocmd FileType ruby setlocal omnifunc=LanguageClient#complete
" Required for operations modifying multiple buffers like rename.
" set hidden
" let g:LanguageClient_serverCommands = {
" \ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
" \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
" \ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
" \ 'python': ['/usr/local/bin/pyls'],
" \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'],
" \ }
" nnoremap <F5> :call LanguageClient_contextMenu()<CR>
" " Or map each action separately
" nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
" nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
" nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
"*****************************************************************************
"" Macros
"*****************************************************************************
nnoremap <leader>gcr If<esc>A # rubocop:disable RSpec/Focus<esc>
nnoremap <leader>sal gg<esc>O$seeds_already_loaded = true<esc><C-o>
nnoremap <leader>gms gg<esc>O$minimal_seeds = true<esc><C-o>
"*****************************************************************************
"" Markdown
"*****************************************************************************
"Markdown plugin
" filetype plugin on
let g:vim_markdown_conceal = 0
let g:vim_markdown_conceal_code_blocks = 0
"Uncomment to override defaults:
"let g:instant_markdown_slow = 1
"let g:instant_markdown_autostart = 0
"let g:instant_markdown_open_to_the_world = 1
"let g:instant_markdown_allow_unsafe_content = 1
"let g:instant_markdown_allow_external_content = 0
"let g:instant_markdown_mathjax = 1
"let g:instant_markdown_logfile = '/tmp/instant_markdown.log'
"let g:instant_markdown_autoscroll = 0
"let g:instant_markdown_port = 8888
"let g:instant_markdown_python = 1
"MarkdownPreview
" set to 1, nvim will open the preview window after entering the markdown buffer
" default: 0
let g:mkdp_auto_start = 1
" set to 1, the nvim will auto close current preview window when change
" from markdown buffer to another buffer
" default: 1
let g:mkdp_auto_close = 1
" set to 1, the vim will refresh markdown when save the buffer or
" leave from insert mode, default 0 is auto refresh markdown as you edit or
" move the cursor
" default: 0
let g:mkdp_refresh_slow = 0
" set to 1, the MarkdownPreview command can be use for all files,
" by default it can be use in markdown file
" default: 0
let g:mkdp_command_for_global = 0
" set to 1, preview server available to others in your network
" by default, the server listens on localhost (127.0.0.1)
" default: 0
let g:mkdp_open_to_the_world = 0
" use custom IP to open preview page
" useful when you work in remote vim and preview on local browser
" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9
" default empty
let g:mkdp_open_ip = ''
" specify browser to open preview page
" default: ''
let g:mkdp_browser = ''
" set to 1, echo preview page url in command line when open preview page
" default is 0
let g:mkdp_echo_preview_url = 0
" a custom vim function name to open preview page
" this function will receive url as param
" default is empty
let g:mkdp_browserfunc = ''
" options for markdown render
" mkit: markdown-it options for render
" katex: katex options for math
" uml: markdown-it-plantuml options
" maid: mermaid options
" disable_sync_scroll: if disable sync scroll, default 0
" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle'
" middle: mean the cursor position alway show at the middle of the preview page
" top: mean the vim top viewport alway show at the top of the preview page
" relative: mean the cursor position alway show at the relative positon of the preview page
" hide_yaml_meta: if hide yaml metadata, default is 1
" sequence_diagrams: js-sequence-diagrams options
" content_editable: if enable content editable for preview page, default: v:false
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1,
\ 'sequence_diagrams': {},
\ 'flowchart_diagrams': {},
\ 'content_editable': v:false
\ }
" use a custom markdown style must be absolute path
" like '/Users/username/markdown.css' or expand('~/markdown.css')
let g:mkdp_markdown_css = ''
" use a custom highlight style must absolute path
" like '/Users/username/highlight.css' or expand('~/highlight.css')
let g:mkdp_highlight_css = ''
" use a custom port to start server or random for empty
let g:mkdp_port = ''
" preview page title
" ${name} will be replace with the file name
let g:mkdp_page_title = '「${name}」'
"*****************************************************************************
"" NERDTree
"*****************************************************************************
"" NERDTree configuration
let g:NERDTreeChDirMode=2
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let g:NERDTreeShowBookmarks=1
let g:nerdtree_tabs_focus_on_files=1
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
let g:NERDTreeWinSize = 50
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
nnoremap <silent> <F2> :NERDTreeFind<CR>
nnoremap <silent> <F3> :NERDTreeToggle<CR>
let g:NERDTreeMapOpenInTab = "l"
"Close NERDTree when you open a file
let NERDTreeQuitOnOpen = 1
"Prettify NERDTree
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
" autocmd FileType nerdtree setlocal noreadonly
"*****************************************************************************
"" polyglot
"*****************************************************************************
" Syntax highlight
" Default highlight is better than polyglot
let g:polyglot_disabled = ['python']
let python_highlight_all = 1
"*****************************************************************************
"" Python
"*****************************************************************************
" vim-python
augroup vimrc-python
autocmd!
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 colorcolumn=79
\ formatoptions+=croq softtabstop=4
\ cinwords=if,elif,else,for,while,try,except,finally,def,class,with
augroup END
"*****************************************************************************
"" jedi-vim
"*****************************************************************************
let g:jedi#popup_on_dot = 0
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_definitions_command = "<leader>d"
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#rename_command = "<leader>r"
let g:jedi#show_call_signatures = "0"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#smart_auto_mappings = 0
"*****************************************************************************
"" ripgrep
"*****************************************************************************
if executable('rg')
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
set grepprg=rg\ --vimgrep
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
endif
"*****************************************************************************
"" rspec.vim
"*****************************************************************************
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
"Prepend `bundle exec`
let g:rspec_command = "!bundle exec rspec {spec}"
"*****************************************************************************
"" Ruby
"*****************************************************************************
"Omnicomplete
let g:ruby_host_prog = '~/.rbenv/shims/neovim-ruby-host'
let g:ruby_path = system('echo $HOME/.rbenv/shims')
" ruby
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
augroup vimrc-ruby
autocmd!
autocmd BufNewFile,BufRead *.rb,*.rbw,*.gemspec setlocal filetype=ruby
autocmd FileType ruby set tabstop=2|set shiftwidth=2|set expandtab softtabstop=2
augroup END
" For ruby refactory
if has('nvim')
runtime! macros/matchit.vim
else
packadd! matchit
endif
" Ruby refactory
nnoremap <leader>rap :RAddParameter<cr>
nnoremap <leader>rcpc :RConvertPostConditional<cr>
nnoremap <leader>rel :RExtractLet<cr>
vnoremap <leader>rec :RExtractConstant<cr>
vnoremap <leader>relv :RExtractLocalVariable<cr>
nnoremap <leader>rit :RInlineTemp<cr>
vnoremap <leader>rrlv :RRenameLocalVariable<cr>
vnoremap <leader>rriv :RRenameInstanceVariable<cr>
vnoremap <leader>rem :RExtractMethod<cr>
"Run RSpec in Tmux
" map <Leader>rt :w<cr>:call RunCurrentTest('!ts be rspec')<CR>
" Thoughtbot Vim-RSpec
let g:rspec_command = "Dispatch bundle exec rspec {spec}"
" let g:rspec_command = "!bundle exec rspec {spec}"
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
" map <LocalLeader>s :e db/schema.rb<CR>
"*****************************************************************************
"" Search
"*****************************************************************************
"" Clean search (highlight)
nnoremap <silent> <leader><space> :noh<cr>
"" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
set fileformats=unix,dos,mac
if exists('$SHELL')
set shell=$SHELL
else
set shell=/bin/sh
endif
"Search for visually selected text
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
"*****************************************************************************
"" Session Management
"*****************************************************************************
nnoremap <leader>so :OpenSession<Space>
nnoremap <leader>ss :SaveSession<Space>
nnoremap <leader>sd :DeleteSession<CR>
nnoremap <leader>sc :CloseSession<CR>
let g:session_directory = "~/.config/nvim/session"
let g:session_autoload = "prompt"
let g:session_autosave = "yes"
let g:session_autosave_periodic = 1
let g:session_command_aliases = 1
let g:session_autosave_silent = 1
"*****************************************************************************
"" The Silver Searcher
"*****************************************************************************
if executable('ag')
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
set grepprg=ag\ --nogroup\ --nocolor
endif
let g:startify_session_dir = '~/.config/nvim/session'
let g:startify_lists = [
\ { 'type': 'files', 'header': [' Files'] },
\ { 'type': 'dir', 'header': [' Current Directory '. getcwd()] },
\ { 'type': 'sessions', 'header': [' Sessions'] },
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
\ ]
let g:startify_bookmarks = [
\ { 'i': '~/.config/nvim/init.vim' },
\ '~/Development/inspiregroup/chameleon/creator/services/creator-backend',
\ '~/Development/publish/clockworkpc.github.io',
\ '~/Development/inspiregroup/chameleon/collect',
\ ]
let g:startify_session_autoload = 1
let g:startify_fortune_use_unicode = 1
let g:startify_session_persistence = 1
let g:startify_enable_special = 0
"*****************************************************************************
"" Tagbar
"*****************************************************************************
nmap <silent> <F4> :TagbarToggle<CR>
let g:tagbar_autofocus = 1
let g:tagbar_type_ruby = {
\ 'kinds' : [
\ 'm:modules',
\ 'c:classes',
\ 'd:describes',
\ 'C:contexts',
\ 'f:methods',
\ 'F:singleton methods'
\ ]
\ }
"*****************************************************************************
"" Terminal Emulation
"*****************************************************************************
" terminal emulation
nnoremap <silent> <leader>sh :terminal<CR>
"Open a terminal in a new tab
map <silent> <M-C-N> :tabnew <bar> :terminal<CR>
"*****************************************************************************
"" textobj-rubyblock
"*****************************************************************************
runtime macros/matchit.vim
set nocompatible
if has("autocmd")
filetype indent plugin on
endif
let g:textobj_ruby_more_mappings = 1
"*****************************************************************************
"" Typescript
"*****************************************************************************
" typescript
let g:yats_host_keyword = 1
"*****************************************************************************
"" UltiSnips
"*****************************************************************************
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
" let g:UltiSnipsExpandTrigger="<tab>"
" let g:UltiSnipsJumpForwardTrigger="<c-b>"
" let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" let g:UltiSnipsEditSplit="vertical"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
let g:UltiSnipsEditSplit="vertical"
" let g:UltiSnipsSnippetDirectories=["UltiSnips", "myUltiSnips"]
"*****************************************************************************
"" vim-airline
"*****************************************************************************
let g:airline_theme = 'powerlineish'
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline#extensions#tagbar#enabled = 1
let g:airline_skip_empty_sections = 1
"python
let g:airline#extensions#virtualenv#enabled = 1
"*****************************************************************************
"" Vimroom
"*****************************************************************************
"Vimroom
let g:goyo_width=100
let g:goyo_margin_top = 2
let g:goyo_margin_bottom = 2
nnoremap <silent> <leader>z :Goyo<cr>
"*****************************************************************************
"" vim-ruby-doc
"*****************************************************************************
" For some reason this plugin doesn't work anymore,
" so I hacked together the same functionality, using its example.
" Replace 'firefox' with whatever command you need instead.
let g:ruby_doc_url_template="http://rubydoc.info/search/stdlib/core?q=%"
let g:rails_doc_url_template="http://api.rubyonrails.org/?q=%"
let g:rspec_doc_url_template='https://www.relishapp.com/rspec/search?query=%'
function! AnyRDoc(url_template)
if &ft =~ "ruby"
else
return
endif
let s:wordUnderCursor = expand("<cword>")
let s:url = substitute(a:url_template, "%", s:wordUnderCursor, "g")
let s:cmd = "!firefox \"" . s:url . "\""
execute s:cmd
endfunction
map RB :call AnyRDoc(ruby_doc_url_template)<CR>
map RR :call AnyRDoc(rails_doc_url_template)<CR>
map RS :call AnyRDoc(rspec_doc_url_template)<CR>
let g:vimwiki_list = [{'path': '~/Development/PanhandleDoorDocuments/', 'path_html': '~/public_html/'}]
"*****************************************************************************
"" visualbell
"*****************************************************************************
" Disable visualbell
set noerrorbells visualbell t_vb=
if has('autocmd')
autocmd GUIEnter * set visualbell t_vb=
endif
"*****************************************************************************
"" Visual Mode
"*****************************************************************************
"" Vmap for maintain Visual Mode after shifting > and <
vmap < <gv
vmap > >gv
"" Move visual block
" vnoremap J :m '>+1<CR>gv=gv
" vnoremap K :m '<-2<CR>gv=gv
"*****************************************************************************
"" Visual Settings
"*****************************************************************************
syntax on
set ruler
set number
let no_buffers_menu=1
set mousemodel=popup
set t_Co=256
set guioptions=egmrti
set gfn=Monospace\ 10
if has("gui_running")
if has("gui_mac") || has("gui_macvim")
set guifont=Menlo:h12
set transparency=7
endif
else
let g:CSApprox_loaded = 1
" IndentLine
let g:indentLine_enabled = 1
let g:indentLine_concealcursor = 0
let g:indentLine_char = '┆'
let g:indentLine_faster = 1
endif
"" Disable the blinking cursor.
set gcr+=a:blinkon0
set scrolloff=3
"" Status bar
set laststatus=2
"" Use modeline overrides
set modeline
set modelines=10
set title
set titleold="Terminal"
set titlestring=%F
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
if exists("*fugitive#statusline")
set statusline+=%{fugitive#statusline()}
endif
"*****************************************************************************
"" XML
"*****************************************************************************
function! DoFormatXML()
:%s/></>\r</g
:0
=:$
endfunction
com! FormatXML call DoFormatXML()
"*****************************************************************************
"" YAML
"*****************************************************************************
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
set foldlevelstart=20
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'
" let g:ale_lint_on_text_changed = 'never'
"*****************************************************************************
"" CPC NEOVIM CONFIGURATION
"" Maintainer: Alexander JK Garber
"*****************************************************************************
"*****************************************************************************
"" Vim-PLug core
"*****************************************************************************
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
let g:vim_bootstrap_langs = "go,haskell,html,javascript,lisp,python,ruby,typescript"
let g:vim_bootstrap_editor = "nvim" " nvim or 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
" Required:
call plug#begin(expand('~/.config/nvim/plugged'))
"****************************************************************************
"" Project
"****************************************************************************
" Functional Start Screen
" Plug 'mhinz/vim-startify'
" Treeview file browser in VIM
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
" Plug 'MarSoft/nerdtree-grep-plugin'
" Status bar above and below
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Show changed lines in gutter
Plug 'airblade/vim-gitgutter'
" Search for strings in files
Plug 'vim-scripts/grep.vim'
"GVim-only colour schemes
Plug 'vim-scripts/CSApprox'
" Fuzzy file search
if isdirectory('/usr/local/opt/fzf')
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
else
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
endif
let g:make = 'gmake'
if exists('make')
let g:make = 'make'
endif
" Find and Replace
Plug 'brooth/far.vim'
" Interactive command execution
Plug 'Shougo/vimproc.vim', {'do': g:make}
"" Vim-Session
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'
" ctags
" Plug 'ludovicchabant/vim-gutentags'
" Plug 'craigemery/vim-autotag'
"codequery
" Plug 'Shougo/unite.vim'
" Plug 'devjoe/vim-codequery'
"grep replace
Plug 'skwp/greplace.vim'
"view images
Plug 'ashisha/image.vim'
"Reload files changed on disk
Plug 'djoshea/vim-autoread'
" Fountain plugin
Plug 'kblin/vim-fountain'
" Close buffers
Plug 'Asheq/close-buffers.vim'
" Conquer of Code (Autocomplete)
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Autosave sessions
Plug 'tpope/vim-obsession'
"Use Vim in the browser
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
"****************************************************************************
"" Editor (NORMAL MODE ONLY)
"****************************************************************************
" Comment out lines with gcc or gc in visual mode
Plug 'tpope/vim-commentary'
" Tag viewer for class and method definitions
Plug 'majutsushi/tagbar'
" Display thin vertical lines for indentations
Plug 'Yggdroot/indentLine'
" Repeat a plug-in command
Plug 'tpope/vim-repeat'
" Improved clipping of text
Plug 'svermeulen/vim-easyclip'
"Replace double quotes, single quotes, etc
Plug 'tpope/vim-surround'
"Split single line to multiline and visa versa
Plug 'AndrewRadev/splitjoin.vim'
"Word Motion
" Plug 'chaoren/vim-wordmotion'
"Resize Windows
Plug 'simeji/winresizer'
"****************************************************************************
"" Editor (INSERT MODE ONLY)
"****************************************************************************
"Autocomplete
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'ervandew/supertab'
"Snippets
Plug 'sirver/UltiSnips'
Plug 'honza/vim-snippets'
" Autocomplete brackets, quotes, etc.
Plug 'Raimondi/delimitMate'
"Markdown tables
Plug 'dhruvasagar/vim-table-mode'
"
"Pairs of handy bracket mappings
Plug 'tpope/vim-unimpaired'
"Horizontal navigation"
Plug 'unblevable/quick-scope'
"Automatic bullet and numbered lists
Plug 'dkarter/bullets.vim'
"Automatic newline and indentation between brackets
Plug 'jiangmiao/auto-pairs'
"Merge git conflicts
Plug 'christoomey/vim-conflicted'
"****************************************************************************
"" Editor (VISUAL MODE ONLY)
"****************************************************************************
"Select a ruby block in VISUAL mode
Plug 'nelstrom/vim-textobj-rubyblock'
" dependency of vim-textobj-rubyblock
Plug 'kana/vim-textobj-user'
"Scratch buffer
" Plug 'mtth/scratch.vim'
"****************************************************************************
"" Editor (COMBINED MODES)
"****************************************************************************
"Make Goyo even nicer
Plug 'amix/vim-zenroom2'
"Code linting
Plug 'dense-analysis/ale'
Plug 'prettier/vim-prettier'
"OrgMode for VIM
Plug 'jceb/vim-orgmode'
"Atomesque coloures
Plug 'joshdick/onedark.vim'
"Distraction-free editing
Plug 'junegunn/goyo.vim'
"Markdown preview
" Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
" Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
" Plug 'iamcco/markdown-preview.nvim'
Plug 'suan/vim-instant-markdown', {'for': 'markdown', 'do': 'yarn install'}
"Floating Terminal
Plug 'voldikss/vim-floaterm'
"Cucumber syntax highlighting
Plug 'barboza/vim-cucumber-string-highlight'
""****************************************************************************
"" Version Control
"****************************************************************************
" Git wrapper
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb' " required by fugitive to :Gbrowse
" GraphQL syntax highlighting
Plug 'jparise/vim-graphql'
"***************************************************************************
"" Ruby and Rails
"***************************************************************************
"Refactor
Plug 'ecomba/vim-ruby-refactoring'
Plug 'thoughtbot/vim-rspec'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-cucumber'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-rake'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-rbenv'
Plug 'thoughtbot/vim-rspec'
Plug 'vim-ruby/vim-ruby'
"Ruby/Rails/RSpec documentation
" Plug 'lucapette/vim-ruby-doc'
" Toggle Ruby do/end and {}
Plug 'jgdavey/vim-blockle'
"***************************************************************************
"" Other Languages
"***************************************************************************
" go
"" Go Lang Bundle
Plug 'fatih/vim-go', {'do': ':GoInstallBinaries'}
" haskell
"" Haskell Bundle
Plug 'eagletmt/neco-ghc'
Plug 'dag/vim2hs'
Plug 'pbrisbin/vim-syntax-shakespeare'
" html
"" HTML Bundle
Plug 'hail2u/vim-css3-syntax'
" Plug 'gorodinskiy/vim-coloresque'
Plug 'tpope/vim-haml'
Plug 'mattn/emmet-vim'
Plug 'zeekay/vim-beautify'
" javascript
"" Javascript Bundle
Plug 'jelera/vim-javascript-syntax'
" lisp
"" Lisp Bundle
Plug 'vim-scripts/slimv.vim'
" python
"" Python Bundle
Plug 'davidhalter/jedi-vim'
Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'}
" typescript
Plug 'leafgarland/typescript-vim'
Plug 'HerringtonDarkholme/yats.vim'
"VimBeGood (Primeagen)
" Plug 'ThePrimeagen/vim-be-good', {'do': './install.sh'}
"FISH Scripting
Plug 'dag/vim-fish'
"Writing Tools
Plug 'preservim/vim-pencil'
Plug 'dbmrq/vim-ditto'
Plug 'honza/writer.vim'
Plug 'mattn/vim-metarw-gdrive'
Plug 'vimwiki/vimwiki'
"*****************************************************************************
call plug#end()
"***************************************************************************
"" Core VIM Keybindings
"***************************************************************************"
" Map leader to ,
let mapleader=','
"map LocalLeader to \\
let maplocalleader = "\\"
"Left (h) => [h]
noremap h h
"Up (j) => [t]
noremap t gj
"Down (k) => [n]
noremap n gk
"Right (l) => [s]
noremap s l
"End of line ($) => [-]
noremap - $
"Start of line (^) => [_]
noremap _ ^
"Jump to letter before (t) => [j]
noremap k t
"Sentences
noremap $ s
"m is shadowed by easyclip plugin
noremap gm m
" j/J moves between search mappings
nnoremap j n
nnoremap J N
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
" nnoremap j nzzzv
" nnoremap J Nzzzv
"Move text down
nnoremap <A-t> :m .+1<CR>==
inoremap <A-t> <Esc>:m .+1<CR>==gi
vnoremap <A-t> :m '>+1<CR>gv=gv
"Move text up
nnoremap <A-n> :m .-2<CR>==
inoremap <A-n> <Esc>:m .-2<CR>==gi
vnoremap <A-n> :m '<-2<CR>gv=gv
"*****************************************************************************
"" Mappings
"*****************************************************************************
"" Split
noremap <Leader>h :<C-u>split<CR>
" New buffer rather than the current file
noremap <Leader>v :<C-u>vnew<CR>
" Current file rather than a new buffer
" noremap <Leader>v :<C-u>vsplit<CR>
"*****************************************************************************
"Customised VIM
"*****************************************************************************
"Show how many lines yanked, inter alia
set report=0
"Hybrid line numbers
:set number relativenumber
:augroup numbertoggle
: autocmd!
: autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
: autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
:augroup END
"More natural movement in INSERT mode
behave mswin
"*****************************************************************************
"" Custom Bindings
"*****************************************************************************
"Fix indentation for the whole file
nnoremap <F7> gg=G<C-o><C-o>
" Bind F8 to fixing problems with ALE
nmap <F8> <Plug>(ale_fix)
"Force filetype 'yaml' for yml files
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml foldmethod=manual
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" autocmd BufNewFile,BufRead *.yml set ft=yaml
"Stop line wrap from breaking words
set linebreak
"Skip out of brackets
inoremap <C-e> <C-o>A
"Replace all
nnoremap S :%s///g<Left><Left><Left>
"Jump to next occurrence in INSERT mode
imap <C-j> <Esc>jcaw
"Replace all within a visual selection
" vnoremap S :s/\%V//g<Left><Left><Left>
"Ctrl-A for select all
" vnnoremap <C-a> ggVG
"Replace all matching strings in visual selection
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
" Close all hidden buffers
nnoremap <silent> <C-q> :Bdelete menu<CR>
function! ALEFixFast()
syntax off
exec "ALEFix"
syntax on
endfunction
"Save file, even if no changes
nor <silent> <Leader>w :w<CR>
vnoremap <silent> <C-w> <C-C>:update<CR>
"Close all buffers and quit Neovim
noremap <Leader>' :qall<CR>
"*****************************************************************************
"" Abbreviations
"*****************************************************************************
"" no one is really happy until you have this shortcuts
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall
"*****************************************************************************
"" ALE
"*****************************************************************************
" LINTERS
let g:ale_linters = {
\ 'gql': ['prettier'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\ 'vim': ['vint'],
\}
function! SettingsTurnOff()
"Turns syntax off only in current buffer
exec "syntax clear"
" exec "set nocursorcolumn"
" exec "set nocursorline"
" exec "set norelativenumber"
endfunction
function! SettingsTurnOn()
exec "syntax on"
" exec "set number relativenumber"
exec "AirlineRefresh"
endfunction
augroup YourGroup
autocmd!
autocmd User ALEFixPre call SettingsTurnOff()
autocmd User ALEFixPost call SettingsTurnOn()
augroup END
" FIXERS
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\}
let g:ale_lint_on_enter = 1
let g:ale_completion_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %(code): %%s [%severity%]'
let g:airline#extensions#ale#enabled = 1
" let g:ale_ruby_rubocop_executable = 'rubocop-daemon exec -- --auto-correct'
" set omnifunc=ale#completion#OmniFunc
"*****************************************************************************
"" Autocmd Rules, Functions
"*****************************************************************************
"" Functions
if !exists('*s:setupWrapping')
function s:setupWrapping()
set wrap
set wm=2
set textwidth=80
endfunction
endif
"*****************************************************************************
"" Autocmd Rules
"*****************************************************************************
"" The PC is fast enough, do syntax highlight syncing from start unless 200 lines
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=200
augroup END
"" Remember cursor position
augroup vimrc-remember-cursor-position
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
"" txt
augroup vimrc-wrapping
autocmd!
autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
augroup END
"" make/cmake
augroup vimrc-make-cmake
autocmd!
autocmd FileType make setlocal noexpandtab
autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
augroup END
set autoread
"*****************************************************************************
"" AUTO PAIRS
"*****************************************************************************
" Jump outside '"({
if !exists('g:AutoPairsShortcutJump')
let g:AutoPairsShortcutJump = '<C-l>'
endif
"*****************************************************************************
"" Buffers, Tabs, Windows
"*****************************************************************************
"" Buffer nav
noremap <leader>x :bn<CR>
"" Close buffer
noremap <leader>c :bd<CR>
"" Enable hidden buffers
" set hidden
"" Switching windows
noremap <C-h> <C-w>h
noremap <C-t> <C-w>j
noremap <C-n> <C-w>k
noremap <C-s> <C-w>l
"" Tabs
nnoremap <Tab> gt
nnoremap <S-Tab> gT
nnoremap <silent> <S-t> :tabnew<CR>
"Scratch buffer
function! Scratch()
tabnew
noswapfile hide enew
setlocal buftype=nofile
setlocal bufhidden=hide
"setlocal nobuflisted
"lcd ~
file scratch
endfunction
"*****************************************************************************
"" COC
"*****************************************************************************
" 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
" let g:coc_global_extensions = ['coc-solargraph']
"*****************************************************************************
"" Copy/Paste/Cut
"*****************************************************************************
if has('unnamedplus')
set clipboard=unnamed,unnamedplus
endif
noremap YY "+y<CR>
noremap <leader>p "+gP<CR>
noremap XX "+x<CR>
if has('macunix')
" pbcopy for OSX copy/paste
vmap <C-x> :!pbcopy<CR>
vmap <C-c> :w !pbcopy<CR><CR>
endif
"*****************************************************************************
"" deoplete
"*****************************************************************************
""deoplete
let g:deoplete#enable_at_startup = 1
let g:auto_complete_popup = "manual"
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ deoplete#mappings#manual_complete()
function! s:check_back_space() abort "{{{
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction"}}}
"*****************************************************************************
"" neosnippet
"*****************************************************************************
" " Plugin key-mappings.
" " Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <C-k> <Plug>(neosnippet_expand_or_jump)
" smap <C-k> <Plug>(neosnippet_expand_or_jump)
" xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
" if has('conceal')
" set conceallevel=2 concealcursor=niv
" endif
" " To use Honza's Vim Snippets
" let g:neosnippet#snippets_directory='~/.config/nvim/plugged/vim-snippets/snippets'
"*****************************************************************************
"" Encoding
"*****************************************************************************
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
let g:far#enable_undo=1
"*****************************************************************************
"" fish
"*****************************************************************************
if &shell =~# 'fish$'
set shell=sh
endif
"*****************************************************************************
"" fzf
"*****************************************************************************
set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
let $FZF_DEFAULT_COMMAND = "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'dist/**' -prune -o -type f -print -o -type l -print 2> /dev/null"
" nnoremap <silent> <leader>b :Buffers<CR>
nnoremap <silent> <leader>e :FZF -m<CR>
"Recovery commands from history through FZF
nmap <leader>y :History:<CR>
"NOTE: To open a file in a new tab CTRL-V, CTRL-X, or CTRL-T
"*****************************************************************************
"" General Settings
"*****************************************************************************
"Use `onedark` colour scheme
" colorscheme onedark
colo onedark
"Syntax highlighting from start unless 1000 lines (instead of 200)
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=1000
augroup END
"Refresh file when changed on disk
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI *
\ if mode() !~ '\v(c|r.?|!|t)' && getcmdwintype() == '' | checktime | endif
"Autowrite
set autowriteall
" :set tabstop=2
" :set shiftwidth=2
" :set expandtab
" Folding
set fdm=syntax
set nofoldenable
" set foldlevel=0
" Built-in Neovim autocomplete
cnoremap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
"NERDTree can modify files
set modifiable
"Add Cucumber filetype detection
au BufRead,BufNewFile *.cucumber set filetype=cucumber
"Various completion plugins require this
filetype plugin on
"Omni completion
" set omnifunc=syntaxcomplete#Complete
"Spell check
nnoremap <F10> :set spell! spelllang=en_gb,lt,fr,he!<CR>
"Center screen when going into INSERT mode
" autocmd InsertEnter * norm zz
"Thin line cursor in INSERT mode
highlight Cursor guifg=white guibg=black
highlight iCursor guifg=white guibg=steelblue
set guicursor=n-v-c:block-Cursor
set guicursor=i:ver25-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait10
"Highlight current line
autocmd InsertEnter,InsertLeave * set cul!
"Auotmatically split to the right
set splitright
"*****************************************************************************
"" Git
"*****************************************************************************
noremap <Leader>ga :Gwrite<CR>
noremap <Leader>gc :Gcommit<CR>
noremap <Leader>gsh :Gpush<CR>
noremap <Leader>gll :Gpull<CR>
noremap <Leader>gs :Gstatus<CR>
noremap <Leader>gb :Gblame<CR>
noremap <Leader>gd :Gvdiff<CR>
noremap <Leader>gr :Gremove<CR>
"" Open current line on GitHub
nnoremap <Leader>o :.Gbrowse<CR>
set diffopt+=vertical
"*****************************************************************************
"" Go Language
"*****************************************************************************
" autocmd BufWritePost *.go !go test
"*****************************************************************************
"" grep.vim
"*****************************************************************************
" grep.vim
nnoremap <silent> <leader>f :Rgrep<CR>
let Grep_Default_Options = '-IR'
let Grep_Skip_Files = '*.log *.db'
let Grep_Skip_Dirs = '.git node_modules'
"*****************************************************************************
"" HTML
"*****************************************************************************
" for html files, 2 spaces
autocmd Filetype html setlocal ts=2 sw=2 expandtab
"View HTML Text
function! ViewHtmlText(url)
if !empty(a:url)
new
setlocal buftype=nofile bufhidden=hide noswapfile
execute 'r !elinks ' . a:url . ' -dump -dump-width ' . winwidth(0)
1d
endif
endfunction
" Save and view text for current html file.
nnoremap <Leader>H :update<Bar>call ViewHtmlText(expand('%:p'))<CR>
" " View text for visually selected url.
vnoremap <Leader>h y:call ViewHtmlText(@*)<CR>
" View text for URL from clipboard.
" On Linux, use @* for current selection or @+ for text in clipboard.
nnoremap <Leader>h :call ViewHtmlText(@+)<CR>
"*****************************************************************************
"" Emmet
"*****************************************************************************
" let g:user_emmet_install_global = 0
" autocmd FileType html,css,erb EmmetInstall
let g:user_emmet_leader_key=','
"*****************************************************************************
"" Indentations, Tabs, Whitespaces
"*****************************************************************************
"" Fix backspace indent
set backspace=indent,eol,start
"" Tabs. May be overridden by autocmd rules
set tabstop=2
set softtabstop=0
set shiftwidth=2
set expandtab
" remove trailing whitespaces
command! FixWhitespace :%s/\s\+$//e
"Fix indentation for the whole file
" nnoremap <F7> gg=G<C-o><C-o>
"*****************************************************************************
"" JavaScript
"*****************************************************************************
" javascript
let g:javascript_enable_domhtmlcss = 1
" vim-javascript
augroup vimrc-javascript
autocmd!
autocmd FileType javascript setl tabstop=4|setl shiftwidth=4|setl expandtab softtabstop=4
augroup END
"*****************************************************************************
"" LanguageClient-Neovim
"*****************************************************************************
" Tell the language client to use the default IP and port
" that Solargraph runs on
" let g:LanguageClient_serverCommands = {
" \ 'ruby': ['tcp://localhost:7658']
" \ }
" Don't send a stop signal to the server when exiting vim.
" This is optional, but I don't like having to restart Solargraph
" every time I restart vim.
" let g:LanguageClient_autoStop = 0
" Configure ruby omni-completion to use the language client:
" autocmd FileType ruby setlocal omnifunc=LanguageClient#complete
" Required for operations modifying multiple buffers like rename.
" set hidden
" let g:LanguageClient_serverCommands = {
" \ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
" \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
" \ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
" \ 'python': ['/usr/local/bin/pyls'],
" \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'],
" \ }
" nnoremap <F5> :call LanguageClient_contextMenu()<CR>
" " Or map each action separately
" nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
" nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
" nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
"*****************************************************************************
"" Macros
"*****************************************************************************
nnoremap <leader>gcr If<esc>A # rubocop:disable RSpec/Focus<esc>
nnoremap <leader>sal gg<esc>O$seeds_already_loaded = true<esc><C-o>
nnoremap <leader>gms gg<esc>O$minimal_seeds = true<esc><C-o>
"*****************************************************************************
"" Markdown
"*****************************************************************************
"Markdown plugin
" filetype plugin on
let g:vim_markdown_conceal = 0
let g:vim_markdown_conceal_code_blocks = 0
"Uncomment to override defaults:
"let g:instant_markdown_slow = 1
"let g:instant_markdown_autostart = 0
"let g:instant_markdown_open_to_the_world = 1
"let g:instant_markdown_allow_unsafe_content = 1
"let g:instant_markdown_allow_external_content = 0
"let g:instant_markdown_mathjax = 1
"let g:instant_markdown_logfile = '/tmp/instant_markdown.log'
"let g:instant_markdown_autoscroll = 0
"let g:instant_markdown_port = 8888
"let g:instant_markdown_python = 1
"MarkdownPreview
" set to 1, nvim will open the preview window after entering the markdown buffer
" default: 0
let g:mkdp_auto_start = 1
" set to 1, the nvim will auto close current preview window when change
" from markdown buffer to another buffer
" default: 1
let g:mkdp_auto_close = 1
" set to 1, the vim will refresh markdown when save the buffer or
" leave from insert mode, default 0 is auto refresh markdown as you edit or
" move the cursor
" default: 0
let g:mkdp_refresh_slow = 0
" set to 1, the MarkdownPreview command can be use for all files,
" by default it can be use in markdown file
" default: 0
let g:mkdp_command_for_global = 0
" set to 1, preview server available to others in your network
" by default, the server listens on localhost (127.0.0.1)
" default: 0
let g:mkdp_open_to_the_world = 0
" use custom IP to open preview page
" useful when you work in remote vim and preview on local browser
" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9
" default empty
let g:mkdp_open_ip = ''
" specify browser to open preview page
" default: ''
let g:mkdp_browser = ''
" set to 1, echo preview page url in command line when open preview page
" default is 0
let g:mkdp_echo_preview_url = 0
" a custom vim function name to open preview page
" this function will receive url as param
" default is empty
let g:mkdp_browserfunc = ''
" options for markdown render
" mkit: markdown-it options for render
" katex: katex options for math
" uml: markdown-it-plantuml options
" maid: mermaid options
" disable_sync_scroll: if disable sync scroll, default 0
" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle'
" middle: mean the cursor position alway show at the middle of the preview page
" top: mean the vim top viewport alway show at the top of the preview page
" relative: mean the cursor position alway show at the relative positon of the preview page
" hide_yaml_meta: if hide yaml metadata, default is 1
" sequence_diagrams: js-sequence-diagrams options
" content_editable: if enable content editable for preview page, default: v:false
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1,
\ 'sequence_diagrams': {},
\ 'flowchart_diagrams': {},
\ 'content_editable': v:false
\ }
" use a custom markdown style must be absolute path
" like '/Users/username/markdown.css' or expand('~/markdown.css')
let g:mkdp_markdown_css = ''
" use a custom highlight style must absolute path
" like '/Users/username/highlight.css' or expand('~/highlight.css')
let g:mkdp_highlight_css = ''
" use a custom port to start server or random for empty
let g:mkdp_port = ''
" preview page title
" ${name} will be replace with the file name
let g:mkdp_page_title = '「${name}」'
"*****************************************************************************
"" NERDTree
"*****************************************************************************
"" NERDTree configuration
let g:NERDTreeChDirMode=2
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let g:NERDTreeShowBookmarks=1
let g:nerdtree_tabs_focus_on_files=1
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
let g:NERDTreeWinSize = 50
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
nnoremap <silent> <F2> :NERDTreeFind<CR>
nnoremap <silent> <F3> :NERDTreeToggle<CR>
let g:NERDTreeMapOpenInTab = "l"
"Close NERDTree when you open a file
let NERDTreeQuitOnOpen = 1
"Prettify NERDTree
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
" autocmd FileType nerdtree setlocal noreadonly
"*****************************************************************************
"" polyglot
"*****************************************************************************
" Syntax highlight
" Default highlight is better than polyglot
let g:polyglot_disabled = ['python']
let python_highlight_all = 1
"*****************************************************************************
"" Python
"*****************************************************************************
" vim-python
augroup vimrc-python
autocmd!
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 colorcolumn=79
\ formatoptions+=croq softtabstop=4
\ cinwords=if,elif,else,for,while,try,except,finally,def,class,with
augroup END
"*****************************************************************************
"" jedi-vim
"*****************************************************************************
let g:jedi#popup_on_dot = 0
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_definitions_command = "<leader>d"
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#rename_command = "<leader>r"
let g:jedi#show_call_signatures = "0"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#smart_auto_mappings = 0
"*****************************************************************************
"" ripgrep
"*****************************************************************************
if executable('rg')
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
set grepprg=rg\ --vimgrep
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
endif
"*****************************************************************************
"" rspec.vim
"*****************************************************************************
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
"Prepend `bundle exec`
let g:rspec_command = "!bundle exec rspec {spec}"
"*****************************************************************************
"" Ruby
"*****************************************************************************
"Omnicomplete
let g:ruby_host_prog = '~/.rbenv/shims/neovim-ruby-host'
let g:ruby_path = system('echo $HOME/.rbenv/shims')
" ruby
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
augroup vimrc-ruby
autocmd!
autocmd BufNewFile,BufRead *.rb,*.rbw,*.gemspec setlocal filetype=ruby
autocmd FileType ruby set tabstop=2|set shiftwidth=2|set expandtab softtabstop=2
augroup END
" For ruby refactory
if has('nvim')
runtime! macros/matchit.vim
else
packadd! matchit
endif
" Ruby refactory
nnoremap <leader>rap :RAddParameter<cr>
nnoremap <leader>rcpc :RConvertPostConditional<cr>
nnoremap <leader>rel :RExtractLet<cr>
vnoremap <leader>rec :RExtractConstant<cr>
vnoremap <leader>relv :RExtractLocalVariable<cr>
nnoremap <leader>rit :RInlineTemp<cr>
vnoremap <leader>rrlv :RRenameLocalVariable<cr>
vnoremap <leader>rriv :RRenameInstanceVariable<cr>
vnoremap <leader>rem :RExtractMethod<cr>
"Run RSpec in Tmux
" map <Leader>rt :w<cr>:call RunCurrentTest('!ts be rspec')<CR>
" Thoughtbot Vim-RSpec
let g:rspec_command = "Dispatch bundle exec rspec {spec}"
" let g:rspec_command = "!bundle exec rspec {spec}"
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
" map <LocalLeader>s :e db/schema.rb<CR>
"*****************************************************************************
"" Search
"*****************************************************************************
"" Clean search (highlight)
nnoremap <silent> <leader><space> :noh<cr>
"" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
set fileformats=unix,dos,mac
if exists('$SHELL')
set shell=$SHELL
else
set shell=/bin/sh
endif
"Search for visually selected text
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
"*****************************************************************************
"" Session Management
"*****************************************************************************
nnoremap <leader>so :OpenSession<Space>
nnoremap <leader>ss :SaveSession<Space>
nnoremap <leader>sd :DeleteSession<CR>
nnoremap <leader>sc :CloseSession<CR>
let g:session_directory = "~/.config/nvim/session"
let g:session_autoload = "no"
let g:session_autosave = "yes"
let g:session_autosave_periodic = 1
let g:session_command_aliases = 1
let g:session_autosave_silent = 1
"*****************************************************************************
"" The Silver Searcher
"*****************************************************************************
if executable('ag')
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
set grepprg=ag\ --nogroup\ --nocolor
endif
let g:startify_session_dir = '~/.config/nvim/session'
let g:startify_lists = [
\ { 'type': 'files', 'header': [' Files'] },
\ { 'type': 'dir', 'header': [' Current Directory '. getcwd()] },
\ { 'type': 'sessions', 'header': [' Sessions'] },
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
\ ]
let g:startify_bookmarks = [
\ { 'i': '~/.config/nvim/init.vim' },
\ '~/Development/inspiregroup/chameleon/creator/services/creator-backend',
\ '~/Development/publish/clockworkpc.github.io',
\ '~/Development/inspiregroup/chameleon/collect',
\ ]
let g:startify_session_autoload = 1
let g:startify_fortune_use_unicode = 1
let g:startify_session_persistence = 1
let g:startify_enable_special = 0
"*****************************************************************************
"" Tagbar
"*****************************************************************************
nmap <silent> <F4> :TagbarToggle<CR>
let g:tagbar_autofocus = 1
let g:tagbar_type_ruby = {
\ 'kinds' : [
\ 'm:modules',
\ 'c:classes',
\ 'd:describes',
\ 'C:contexts',
\ 'f:methods',
\ 'F:singleton methods'
\ ]
\ }
"*****************************************************************************
"" Terminal Emulation
"*****************************************************************************
" terminal emulation
nnoremap <silent> <leader>sh :terminal<CR>
"Open a terminal in a new tab
map <silent> <M-C-N> :tabnew <bar> :terminal<CR>
"*****************************************************************************
"" textobj-rubyblock
"*****************************************************************************
runtime macros/matchit.vim
set nocompatible
if has("autocmd")
filetype indent plugin on
endif
let g:textobj_ruby_more_mappings = 1
"*****************************************************************************
"" Typescript
"*****************************************************************************
" typescript
let g:yats_host_keyword = 1
"*****************************************************************************
"" UltiSnips
"*****************************************************************************
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
" let g:UltiSnipsExpandTrigger="<tab>"
" let g:UltiSnipsJumpForwardTrigger="<c-b>"
" let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" let g:UltiSnipsEditSplit="vertical"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
let g:UltiSnipsEditSplit="vertical"
" let g:UltiSnipsSnippetDirectories=["UltiSnips", "myUltiSnips"]
"*****************************************************************************
"" vim-airline
"*****************************************************************************
let g:airline_theme = 'powerlineish'
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline#extensions#tagbar#enabled = 1
let g:airline_skip_empty_sections = 1
"python
let g:airline#extensions#virtualenv#enabled = 1
"*****************************************************************************
"" Vimroom
"*****************************************************************************
"Vimroom
let g:goyo_width=100
let g:goyo_margin_top = 2
let g:goyo_margin_bottom = 2
nnoremap <silent> <leader>z :Goyo<cr>
"*****************************************************************************
"" vim-ruby-doc
"*****************************************************************************
" For some reason this plugin doesn't work anymore,
" so I hacked together the same functionality, using its example.
" Replace 'firefox' with whatever command you need instead.
let g:ruby_doc_url_template="http://rubydoc.info/search/stdlib/core?q=%"
let g:rails_doc_url_template="http://api.rubyonrails.org/?q=%"
let g:rspec_doc_url_template='https://www.relishapp.com/rspec/search?query=%'
function! AnyRDoc(url_template)
if &ft =~ "ruby"
else
return
endif
let s:wordUnderCursor = expand("<cword>")
let s:url = substitute(a:url_template, "%", s:wordUnderCursor, "g")
let s:cmd = "!firefox \"" . s:url . "\""
execute s:cmd
endfunction
map RB :call AnyRDoc(ruby_doc_url_template)<CR>
map RR :call AnyRDoc(rails_doc_url_template)<CR>
map RS :call AnyRDoc(rspec_doc_url_template)<CR>
let g:vimwiki_list = [{'path': '~/Development/PanhandleDoorDocuments/', 'path_html': '~/public_html/'}]
"*****************************************************************************
"" visualbell
"*****************************************************************************
" Disable visualbell
set noerrorbells visualbell t_vb=
if has('autocmd')
autocmd GUIEnter * set visualbell t_vb=
endif
"*****************************************************************************
"" Visual Mode
"*****************************************************************************
"" Vmap for maintain Visual Mode after shifting > and <
vmap < <gv
vmap > >gv
"" Move visual block
" vnoremap J :m '>+1<CR>gv=gv
" vnoremap K :m '<-2<CR>gv=gv
"*****************************************************************************
"" Visual Settings
"*****************************************************************************
syntax on
set ruler
set number
let no_buffers_menu=1
set mousemodel=popup
set t_Co=256
set guioptions=egmrti
set gfn=Monospace\ 10
if has("gui_running")
if has("gui_mac") || has("gui_macvim")
set guifont=Menlo:h12
set transparency=7
endif
else
let g:CSApprox_loaded = 1
" IndentLine
let g:indentLine_enabled = 1
let g:indentLine_concealcursor = 0
let g:indentLine_char = '┆'
let g:indentLine_faster = 1
endif
"" Disable the blinking cursor.
set gcr+=a:blinkon0
set scrolloff=3
"" Status bar
set laststatus=2
"" Use modeline overrides
set modeline
set modelines=10
set title
set titleold="Terminal"
set titlestring=%F
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
if exists("*fugitive#statusline")
set statusline+=%{fugitive#statusline()}
endif
"*****************************************************************************
"" XML
"*****************************************************************************
function! DoFormatXML()
:%s/></>\r</g
:0
=:$
endfunction
com! FormatXML call DoFormatXML()
"*****************************************************************************
"" YAML
"*****************************************************************************
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
set foldlevelstart=20
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'
" let g:ale_lint_on_text_changed = 'never'
"*****************************************************************************
"" CPC NEOVIM CONFIGURATION
"" Maintainer: Alexander JK Garber
"*****************************************************************************
"*****************************************************************************
"" Vim-PLug core
"*****************************************************************************
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
let g:vim_bootstrap_langs = "go,haskell,html,javascript,lisp,python,ruby,typescript"
let g:vim_bootstrap_editor = "nvim" " nvim or 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
" Required:
call plug#begin(expand('~/.config/nvim/plugged'))
"****************************************************************************
"" Project
"****************************************************************************
" Functional Start Screen
" Plug 'mhinz/vim-startify'
" Treeview file browser in VIM
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
" Plug 'MarSoft/nerdtree-grep-plugin'
" Status bar above and below
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Show changed lines in gutter
Plug 'airblade/vim-gitgutter'
" Search for strings in files
Plug 'vim-scripts/grep.vim'
"GVim-only colour schemes
Plug 'vim-scripts/CSApprox'
" Fuzzy file search
if isdirectory('/usr/local/opt/fzf')
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
else
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
endif
let g:make = 'gmake'
if exists('make')
let g:make = 'make'
endif
" Find and Replace
Plug 'brooth/far.vim'
" Interactive command execution
Plug 'Shougo/vimproc.vim', {'do': g:make}
"" Vim-Session
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'
" ctags
" Plug 'ludovicchabant/vim-gutentags'
" Plug 'craigemery/vim-autotag'
"codequery
" Plug 'Shougo/unite.vim'
" Plug 'devjoe/vim-codequery'
"grep replace
Plug 'skwp/greplace.vim'
"view images
Plug 'ashisha/image.vim'
"Reload files changed on disk
Plug 'djoshea/vim-autoread'
" Fountain plugin
Plug 'kblin/vim-fountain'
" Close buffers
Plug 'Asheq/close-buffers.vim'
" Conquer of Code (Autocomplete)
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Autosave sessions
Plug 'tpope/vim-obsession'
"Use Vim in the browser
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
"****************************************************************************
"" Editor (NORMAL MODE ONLY)
"****************************************************************************
" Comment out lines with gcc or gc in visual mode
Plug 'tpope/vim-commentary'
" Tag viewer for class and method definitions
Plug 'majutsushi/tagbar'
" Display thin vertical lines for indentations
Plug 'Yggdroot/indentLine'
" Repeat a plug-in command
Plug 'tpope/vim-repeat'
" Improved clipping of text
Plug 'svermeulen/vim-easyclip'
"Replace double quotes, single quotes, etc
Plug 'tpope/vim-surround'
"Split single line to multiline and visa versa
Plug 'AndrewRadev/splitjoin.vim'
"Word Motion
" Plug 'chaoren/vim-wordmotion'
"Resize Windows
Plug 'simeji/winresizer'
"****************************************************************************
"" Editor (INSERT MODE ONLY)
"****************************************************************************
"Autocomplete
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'ervandew/supertab'
"Snippets
Plug 'sirver/UltiSnips'
Plug 'honza/vim-snippets'
" Autocomplete brackets, quotes, etc.
Plug 'Raimondi/delimitMate'
"Markdown tables
Plug 'dhruvasagar/vim-table-mode'
"
"Pairs of handy bracket mappings
Plug 'tpope/vim-unimpaired'
"Horizontal navigation"
Plug 'unblevable/quick-scope'
"Automatic bullet and numbered lists
Plug 'dkarter/bullets.vim'
"Automatic newline and indentation between brackets
Plug 'jiangmiao/auto-pairs'
"Merge git conflicts
Plug 'christoomey/vim-conflicted'
"****************************************************************************
"" Editor (VISUAL MODE ONLY)
"****************************************************************************
"Select a ruby block in VISUAL mode
Plug 'nelstrom/vim-textobj-rubyblock'
" dependency of vim-textobj-rubyblock
Plug 'kana/vim-textobj-user'
"Scratch buffer
" Plug 'mtth/scratch.vim'
"****************************************************************************
"" Editor (COMBINED MODES)
"****************************************************************************
"Make Goyo even nicer
Plug 'amix/vim-zenroom2'
"Code linting
Plug 'dense-analysis/ale'
Plug 'prettier/vim-prettier'
"OrgMode for VIM
Plug 'jceb/vim-orgmode'
"Atomesque coloures
Plug 'joshdick/onedark.vim'
"Distraction-free editing
Plug 'junegunn/goyo.vim'
"Markdown preview
" Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
" Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
" Plug 'iamcco/markdown-preview.nvim'
Plug 'suan/vim-instant-markdown', {'for': 'markdown', 'do': 'yarn install'}
"Floating Terminal
Plug 'voldikss/vim-floaterm'
"Cucumber syntax highlighting
Plug 'barboza/vim-cucumber-string-highlight'
""****************************************************************************
"" Version Control
"****************************************************************************
" Git wrapper
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb' " required by fugitive to :Gbrowse
" GraphQL syntax highlighting
Plug 'jparise/vim-graphql'
"***************************************************************************
"" Ruby and Rails
"***************************************************************************
"Refactor
Plug 'ecomba/vim-ruby-refactoring'
Plug 'thoughtbot/vim-rspec'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-cucumber'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-rake'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-rbenv'
Plug 'thoughtbot/vim-rspec'
Plug 'vim-ruby/vim-ruby'
"Ruby/Rails/RSpec documentation
" Plug 'lucapette/vim-ruby-doc'
" Toggle Ruby do/end and {}
Plug 'jgdavey/vim-blockle'
"***************************************************************************
"" Other Languages
"***************************************************************************
" go
"" Go Lang Bundle
Plug 'fatih/vim-go', {'do': ':GoInstallBinaries'}
" haskell
"" Haskell Bundle
Plug 'eagletmt/neco-ghc'
Plug 'dag/vim2hs'
Plug 'pbrisbin/vim-syntax-shakespeare'
" html
"" HTML Bundle
Plug 'hail2u/vim-css3-syntax'
" Plug 'gorodinskiy/vim-coloresque'
Plug 'tpope/vim-haml'
Plug 'mattn/emmet-vim'
Plug 'zeekay/vim-beautify'
" javascript
"" Javascript Bundle
Plug 'jelera/vim-javascript-syntax'
" lisp
"" Lisp Bundle
Plug 'vim-scripts/slimv.vim'
" python
"" Python Bundle
Plug 'davidhalter/jedi-vim'
Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'}
" typescript
Plug 'leafgarland/typescript-vim'
Plug 'HerringtonDarkholme/yats.vim'
"VimBeGood (Primeagen)
" Plug 'ThePrimeagen/vim-be-good', {'do': './install.sh'}
"FISH Scripting
Plug 'dag/vim-fish'
"Writing Tools
Plug 'preservim/vim-pencil'
Plug 'dbmrq/vim-ditto'
Plug 'honza/writer.vim'
Plug 'mattn/vim-metarw-gdrive'
" Plug 'vimwiki/vimwiki'
"*****************************************************************************
call plug#end()
"***************************************************************************
"" Core VIM Keybindings
"***************************************************************************"
" Map leader to ,
let mapleader=','
"map LocalLeader to \\
let maplocalleader = "\\"
"Left (h) => [h]
noremap h h
"Up (j) => [t]
noremap t gj
"Down (k) => [n]
noremap n gk
"Right (l) => [s]
noremap s l
"End of line ($) => [-]
noremap - $
"Start of line (^) => [_]
noremap _ ^
"Jump to letter before (t) => [j]
noremap k t
"Sentences
noremap $ s
"m is shadowed by easyclip plugin
noremap gm m
" j/J moves between search mappings
nnoremap j n
nnoremap J N
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
" nnoremap j nzzzv
" nnoremap J Nzzzv
"Move text down
nnoremap <A-t> :m .+1<CR>==
inoremap <A-t> <Esc>:m .+1<CR>==gi
vnoremap <A-t> :m '>+1<CR>gv=gv
"Move text up
nnoremap <A-n> :m .-2<CR>==
inoremap <A-n> <Esc>:m .-2<CR>==gi
vnoremap <A-n> :m '<-2<CR>gv=gv
"*****************************************************************************
"" Mappings
"*****************************************************************************
"" Split
noremap <Leader>h :<C-u>split<CR>
" New buffer rather than the current file
noremap <Leader>v :<C-u>vnew<CR>
" Current file rather than a new buffer
" noremap <Leader>v :<C-u>vsplit<CR>
"*****************************************************************************
"Customised VIM
"*****************************************************************************
"Show how many lines yanked, inter alia
set report=0
"Hybrid line numbers
:set number relativenumber
:augroup numbertoggle
: autocmd!
: autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
: autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
:augroup END
"More natural movement in INSERT mode
behave mswin
"*****************************************************************************
"" Custom Bindings
"*****************************************************************************
"Fix indentation for the whole file
nnoremap <F7> gg=G<C-o><C-o>
" Bind F8 to fixing problems with ALE
nmap <F8> <Plug>(ale_fix)
"Force filetype 'yaml' for yml files
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml foldmethod=manual
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" autocmd BufNewFile,BufRead *.yml set ft=yaml
"Stop line wrap from breaking words
set linebreak
"Skip out of brackets
inoremap <C-e> <C-o>A
"Replace all
nnoremap S :%s///g<Left><Left><Left>
"Jump to next occurrence in INSERT mode
imap <C-j> <Esc>jcaw
"Replace all within a visual selection
" vnoremap S :s/\%V//g<Left><Left><Left>
"Ctrl-A for select all
" vnnoremap <C-a> ggVG
"Replace all matching strings in visual selection
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
" Close all hidden buffers
nnoremap <silent> <C-q> :Bdelete menu<CR>
function! ALEFixFast()
syntax off
exec "ALEFix"
syntax on
endfunction
"Save file, even if no changes
nor <silent> <Leader>w :w<CR>
vnoremap <silent> <C-w> <C-C>:update<CR>
"Close all buffers and quit Neovim
noremap <Leader>' :qall<CR>
"*****************************************************************************
"" Abbreviations
"*****************************************************************************
"" no one is really happy until you have this shortcuts
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall
"*****************************************************************************
"" ALE
"*****************************************************************************
" LINTERS
let g:ale_linters = {
\ 'gql': ['prettier'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\ 'vim': ['vint'],
\}
function! SettingsTurnOff()
"Turns syntax off only in current buffer
exec "syntax clear"
" exec "set nocursorcolumn"
" exec "set nocursorline"
" exec "set norelativenumber"
endfunction
function! SettingsTurnOn()
exec "syntax on"
" exec "set number relativenumber"
exec "AirlineRefresh"
endfunction
augroup YourGroup
autocmd!
autocmd User ALEFixPre call SettingsTurnOff()
autocmd User ALEFixPost call SettingsTurnOn()
augroup END
" FIXERS
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\}
let g:ale_lint_on_enter = 1
let g:ale_completion_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %(code): %%s [%severity%]'
let g:airline#extensions#ale#enabled = 1
" let g:ale_ruby_rubocop_executable = 'rubocop-daemon exec -- --auto-correct'
" set omnifunc=ale#completion#OmniFunc
"*****************************************************************************
"" Autocmd Rules, Functions
"*****************************************************************************
"" Functions
if !exists('*s:setupWrapping')
function s:setupWrapping()
set wrap
set wm=2
set textwidth=80
endfunction
endif
"*****************************************************************************
"" Autocmd Rules
"*****************************************************************************
"" The PC is fast enough, do syntax highlight syncing from start unless 200 lines
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=200
augroup END
"" Remember cursor position
augroup vimrc-remember-cursor-position
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
"" txt
augroup vimrc-wrapping
autocmd!
autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
augroup END
"" make/cmake
augroup vimrc-make-cmake
autocmd!
autocmd FileType make setlocal noexpandtab
autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
augroup END
set autoread
"*****************************************************************************
"" AUTO PAIRS
"*****************************************************************************
" Jump outside '"({
if !exists('g:AutoPairsShortcutJump')
let g:AutoPairsShortcutJump = '<C-l>'
endif
"*****************************************************************************
"" Buffers, Tabs, Windows
"*****************************************************************************
"" Buffer nav
noremap <leader>x :bn<CR>
"" Close buffer
noremap <leader>c :bd<CR>
"" Enable hidden buffers
" set hidden
"" Switching windows
noremap <C-h> <C-w>h
noremap <C-t> <C-w>j
noremap <C-n> <C-w>k
noremap <C-s> <C-w>l
"" Tabs
nnoremap <Tab> gt
nnoremap <S-Tab> gT
nnoremap <silent> <S-t> :tabnew<CR>
"Scratch buffer
function! Scratch()
tabnew
noswapfile hide enew
setlocal buftype=nofile
setlocal bufhidden=hide
"setlocal nobuflisted
"lcd ~
file scratch
endfunction
"*****************************************************************************
"" COC
"*****************************************************************************
" 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
" let g:coc_global_extensions = ['coc-solargraph']
"*****************************************************************************
"" Copy/Paste/Cut
"*****************************************************************************
if has('unnamedplus')
set clipboard=unnamed,unnamedplus
endif
noremap YY "+y<CR>
noremap <leader>p "+gP<CR>
noremap XX "+x<CR>
if has('macunix')
" pbcopy for OSX copy/paste
vmap <C-x> :!pbcopy<CR>
vmap <C-c> :w !pbcopy<CR><CR>
endif
"*****************************************************************************
"" deoplete
"*****************************************************************************
""deoplete
let g:deoplete#enable_at_startup = 1
let g:auto_complete_popup = "manual"
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ deoplete#mappings#manual_complete()
function! s:check_back_space() abort "{{{
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction"}}}
"*****************************************************************************
"" neosnippet
"*****************************************************************************
" " Plugin key-mappings.
" " Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <C-k> <Plug>(neosnippet_expand_or_jump)
" smap <C-k> <Plug>(neosnippet_expand_or_jump)
" xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
" if has('conceal')
" set conceallevel=2 concealcursor=niv
" endif
" " To use Honza's Vim Snippets
" let g:neosnippet#snippets_directory='~/.config/nvim/plugged/vim-snippets/snippets'
"*****************************************************************************
"" Encoding
"*****************************************************************************
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
let g:far#enable_undo=1
"*****************************************************************************
"" fish
"*****************************************************************************
if &shell =~# 'fish$'
set shell=sh
endif
"*****************************************************************************
"" fzf
"*****************************************************************************
set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
let $FZF_DEFAULT_COMMAND = "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'dist/**' -prune -o -type f -print -o -type l -print 2> /dev/null"
" nnoremap <silent> <leader>b :Buffers<CR>
nnoremap <silent> <leader>e :FZF -m<CR>
"Recovery commands from history through FZF
nmap <leader>y :History:<CR>
"NOTE: To open a file in a new tab CTRL-V, CTRL-X, or CTRL-T
"*****************************************************************************
"" General Settings
"*****************************************************************************
"Use `onedark` colour scheme
" colorscheme onedark
colo onedark
"Syntax highlighting from start unless 1000 lines (instead of 200)
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=1000
augroup END
"Refresh file when changed on disk
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI *
\ if mode() !~ '\v(c|r.?|!|t)' && getcmdwintype() == '' | checktime | endif
"Autowrite
set autowriteall
" :set tabstop=2
" :set shiftwidth=2
" :set expandtab
" Folding
set fdm=syntax
set nofoldenable
" set foldlevel=0
" Built-in Neovim autocomplete
cnoremap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
"NERDTree can modify files
set modifiable
"Add Cucumber filetype detection
au BufRead,BufNewFile *.cucumber set filetype=cucumber
"Various completion plugins require this
filetype plugin on
"Omni completion
" set omnifunc=syntaxcomplete#Complete
"Spell check
nnoremap <F10> :set spell! spelllang=en_gb,lt,fr,he!<CR>
"Center screen when going into INSERT mode
" autocmd InsertEnter * norm zz
"Thin line cursor in INSERT mode
highlight Cursor guifg=white guibg=black
highlight iCursor guifg=white guibg=steelblue
set guicursor=n-v-c:block-Cursor
set guicursor=i:ver25-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait10
"Highlight current line
autocmd InsertEnter,InsertLeave * set cul!
"Auotmatically split to the right
set splitright
"*****************************************************************************
"" Git
"*****************************************************************************
noremap <Leader>ga :Gwrite<CR>
noremap <Leader>gc :Gcommit<CR>
noremap <Leader>gsh :Gpush<CR>
noremap <Leader>gll :Gpull<CR>
noremap <Leader>gs :Gstatus<CR>
noremap <Leader>gb :Gblame<CR>
noremap <Leader>gd :Gvdiff<CR>
noremap <Leader>gr :Gremove<CR>
"" Open current line on GitHub
nnoremap <Leader>o :.Gbrowse<CR>
set diffopt+=vertical
"*****************************************************************************
"" Go Language
"*****************************************************************************
" autocmd BufWritePost *.go !go test
"*****************************************************************************
"" grep.vim
"*****************************************************************************
" grep.vim
nnoremap <silent> <leader>f :Rgrep<CR>
let Grep_Default_Options = '-IR'
let Grep_Skip_Files = '*.log *.db'
let Grep_Skip_Dirs = '.git node_modules'
"*****************************************************************************
"" HTML
"*****************************************************************************
" for html files, 2 spaces
autocmd Filetype html setlocal ts=2 sw=2 expandtab
"View HTML Text
function! ViewHtmlText(url)
if !empty(a:url)
new
setlocal buftype=nofile bufhidden=hide noswapfile
execute 'r !elinks ' . a:url . ' -dump -dump-width ' . winwidth(0)
1d
endif
endfunction
" Save and view text for current html file.
nnoremap <Leader>H :update<Bar>call ViewHtmlText(expand('%:p'))<CR>
" " View text for visually selected url.
vnoremap <Leader>h y:call ViewHtmlText(@*)<CR>
" View text for URL from clipboard.
" On Linux, use @* for current selection or @+ for text in clipboard.
nnoremap <Leader>h :call ViewHtmlText(@+)<CR>
"*****************************************************************************
"" Emmet
"*****************************************************************************
" let g:user_emmet_install_global = 0
" autocmd FileType html,css,erb EmmetInstall
let g:user_emmet_leader_key=','
"*****************************************************************************
"" Indentations, Tabs, Whitespaces
"*****************************************************************************
"" Fix backspace indent
set backspace=indent,eol,start
"" Tabs. May be overridden by autocmd rules
set tabstop=2
set softtabstop=0
set shiftwidth=2
set expandtab
" remove trailing whitespaces
command! FixWhitespace :%s/\s\+$//e
"Fix indentation for the whole file
" nnoremap <F7> gg=G<C-o><C-o>
"*****************************************************************************
"" JavaScript
"*****************************************************************************
" javascript
let g:javascript_enable_domhtmlcss = 1
" vim-javascript
augroup vimrc-javascript
autocmd!
autocmd FileType javascript setl tabstop=4|setl shiftwidth=4|setl expandtab softtabstop=4
augroup END
"*****************************************************************************
"" LanguageClient-Neovim
"*****************************************************************************
" Tell the language client to use the default IP and port
" that Solargraph runs on
" let g:LanguageClient_serverCommands = {
" \ 'ruby': ['tcp://localhost:7658']
" \ }
" Don't send a stop signal to the server when exiting vim.
" This is optional, but I don't like having to restart Solargraph
" every time I restart vim.
" let g:LanguageClient_autoStop = 0
" Configure ruby omni-completion to use the language client:
" autocmd FileType ruby setlocal omnifunc=LanguageClient#complete
" Required for operations modifying multiple buffers like rename.
" set hidden
" let g:LanguageClient_serverCommands = {
" \ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
" \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
" \ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
" \ 'python': ['/usr/local/bin/pyls'],
" \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'],
" \ }
" nnoremap <F5> :call LanguageClient_contextMenu()<CR>
" " Or map each action separately
" nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
" nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
" nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
"*****************************************************************************
"" Macros
"*****************************************************************************
nnoremap <leader>gcr If<esc>A # rubocop:disable RSpec/Focus<esc>
nnoremap <leader>sal gg<esc>O$seeds_already_loaded = true<esc><C-o>
nnoremap <leader>gms gg<esc>O$minimal_seeds = true<esc><C-o>
"*****************************************************************************
"" Markdown
"*****************************************************************************
"Markdown plugin
" filetype plugin on
let g:vim_markdown_conceal = 0
let g:vim_markdown_conceal_code_blocks = 0
"Uncomment to override defaults:
"let g:instant_markdown_slow = 1
"let g:instant_markdown_autostart = 0
"let g:instant_markdown_open_to_the_world = 1
"let g:instant_markdown_allow_unsafe_content = 1
"let g:instant_markdown_allow_external_content = 0
"let g:instant_markdown_mathjax = 1
"let g:instant_markdown_logfile = '/tmp/instant_markdown.log'
"let g:instant_markdown_autoscroll = 0
"let g:instant_markdown_port = 8888
"let g:instant_markdown_python = 1
"MarkdownPreview
" set to 1, nvim will open the preview window after entering the markdown buffer
" default: 0
let g:mkdp_auto_start = 1
" set to 1, the nvim will auto close current preview window when change
" from markdown buffer to another buffer
" default: 1
let g:mkdp_auto_close = 1
" set to 1, the vim will refresh markdown when save the buffer or
" leave from insert mode, default 0 is auto refresh markdown as you edit or
" move the cursor
" default: 0
let g:mkdp_refresh_slow = 0
" set to 1, the MarkdownPreview command can be use for all files,
" by default it can be use in markdown file
" default: 0
let g:mkdp_command_for_global = 0
" set to 1, preview server available to others in your network
" by default, the server listens on localhost (127.0.0.1)
" default: 0
let g:mkdp_open_to_the_world = 0
" use custom IP to open preview page
" useful when you work in remote vim and preview on local browser
" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9
" default empty
let g:mkdp_open_ip = ''
" specify browser to open preview page
" default: ''
let g:mkdp_browser = ''
" set to 1, echo preview page url in command line when open preview page
" default is 0
let g:mkdp_echo_preview_url = 0
" a custom vim function name to open preview page
" this function will receive url as param
" default is empty
let g:mkdp_browserfunc = ''
" options for markdown render
" mkit: markdown-it options for render
" katex: katex options for math
" uml: markdown-it-plantuml options
" maid: mermaid options
" disable_sync_scroll: if disable sync scroll, default 0
" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle'
" middle: mean the cursor position alway show at the middle of the preview page
" top: mean the vim top viewport alway show at the top of the preview page
" relative: mean the cursor position alway show at the relative positon of the preview page
" hide_yaml_meta: if hide yaml metadata, default is 1
" sequence_diagrams: js-sequence-diagrams options
" content_editable: if enable content editable for preview page, default: v:false
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1,
\ 'sequence_diagrams': {},
\ 'flowchart_diagrams': {},
\ 'content_editable': v:false
\ }
" use a custom markdown style must be absolute path
" like '/Users/username/markdown.css' or expand('~/markdown.css')
let g:mkdp_markdown_css = ''
" use a custom highlight style must absolute path
" like '/Users/username/highlight.css' or expand('~/highlight.css')
let g:mkdp_highlight_css = ''
" use a custom port to start server or random for empty
let g:mkdp_port = ''
" preview page title
" ${name} will be replace with the file name
let g:mkdp_page_title = '「${name}」'
"*****************************************************************************
"" NERDTree
"*****************************************************************************
"" NERDTree configuration
let g:NERDTreeChDirMode=2
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let g:NERDTreeShowBookmarks=1
let g:nerdtree_tabs_focus_on_files=1
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
let g:NERDTreeWinSize = 50
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
nnoremap <silent> <F2> :NERDTreeFind<CR>
nnoremap <silent> <F3> :NERDTreeToggle<CR>
let g:NERDTreeMapOpenInTab = "l"
"Close NERDTree when you open a file
let NERDTreeQuitOnOpen = 1
"Prettify NERDTree
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
" autocmd FileType nerdtree setlocal noreadonly
"*****************************************************************************
"" polyglot
"*****************************************************************************
" Syntax highlight
" Default highlight is better than polyglot
let g:polyglot_disabled = ['python']
let python_highlight_all = 1
"*****************************************************************************
"" Python
"*****************************************************************************
" vim-python
augroup vimrc-python
autocmd!
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 colorcolumn=79
\ formatoptions+=croq softtabstop=4
\ cinwords=if,elif,else,for,while,try,except,finally,def,class,with
augroup END
"*****************************************************************************
"" jedi-vim
"*****************************************************************************
let g:jedi#popup_on_dot = 0
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_definitions_command = "<leader>d"
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#rename_command = "<leader>r"
let g:jedi#show_call_signatures = "0"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#smart_auto_mappings = 0
"*****************************************************************************
"" ripgrep
"*****************************************************************************
if executable('rg')
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
set grepprg=rg\ --vimgrep
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
endif
"*****************************************************************************
"" rspec.vim
"*****************************************************************************
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
"Prepend `bundle exec`
let g:rspec_command = "!bundle exec rspec {spec}"
"*****************************************************************************
"" Ruby
"*****************************************************************************
"Omnicomplete
let g:ruby_host_prog = '~/.rbenv/shims/neovim-ruby-host'
let g:ruby_path = system('echo $HOME/.rbenv/shims')
" ruby
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
augroup vimrc-ruby
autocmd!
autocmd BufNewFile,BufRead *.rb,*.rbw,*.gemspec setlocal filetype=ruby
autocmd FileType ruby set tabstop=2|set shiftwidth=2|set expandtab softtabstop=2
augroup END
" For ruby refactory
if has('nvim')
runtime! macros/matchit.vim
else
packadd! matchit
endif
" Ruby refactory
nnoremap <leader>rap :RAddParameter<cr>
nnoremap <leader>rcpc :RConvertPostConditional<cr>
nnoremap <leader>rel :RExtractLet<cr>
vnoremap <leader>rec :RExtractConstant<cr>
vnoremap <leader>relv :RExtractLocalVariable<cr>
nnoremap <leader>rit :RInlineTemp<cr>
vnoremap <leader>rrlv :RRenameLocalVariable<cr>
vnoremap <leader>rriv :RRenameInstanceVariable<cr>
vnoremap <leader>rem :RExtractMethod<cr>
"Run RSpec in Tmux
" map <Leader>rt :w<cr>:call RunCurrentTest('!ts be rspec')<CR>
" Thoughtbot Vim-RSpec
let g:rspec_command = "Dispatch bundle exec rspec {spec}"
" let g:rspec_command = "!bundle exec rspec {spec}"
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
" map <LocalLeader>s :e db/schema.rb<CR>
"*****************************************************************************
"" Search
"*****************************************************************************
"" Clean search (highlight)
nnoremap <silent> <leader><space> :noh<cr>
"" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
set fileformats=unix,dos,mac
if exists('$SHELL')
set shell=$SHELL
else
set shell=/bin/sh
endif
"Search for visually selected text
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
"*****************************************************************************
"" Session Management
"*****************************************************************************
nnoremap <leader>so :OpenSession<Space>
nnoremap <leader>ss :SaveSession<Space>
nnoremap <leader>sd :DeleteSession<CR>
nnoremap <leader>sc :CloseSession<CR>
let g:session_directory = "~/.config/nvim/session"
let g:session_autoload = "no"
let g:session_autosave = "yes"
let g:session_autosave_periodic = 1
let g:session_command_aliases = 1
let g:session_autosave_silent = 1
"*****************************************************************************
"" The Silver Searcher
"*****************************************************************************
if executable('ag')
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
set grepprg=ag\ --nogroup\ --nocolor
endif
let g:startify_session_dir = '~/.config/nvim/session'
let g:startify_lists = [
\ { 'type': 'files', 'header': [' Files'] },
\ { 'type': 'dir', 'header': [' Current Directory '. getcwd()] },
\ { 'type': 'sessions', 'header': [' Sessions'] },
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
\ ]
let g:startify_bookmarks = [
\ { 'i': '~/.config/nvim/init.vim' },
\ '~/Development/inspiregroup/chameleon/creator/services/creator-backend',
\ '~/Development/publish/clockworkpc.github.io',
\ '~/Development/inspiregroup/chameleon/collect',
\ ]
let g:startify_session_autoload = 1
let g:startify_fortune_use_unicode = 1
let g:startify_session_persistence = 1
let g:startify_enable_special = 0
"*****************************************************************************
"" Tagbar
"*****************************************************************************
nmap <silent> <F4> :TagbarToggle<CR>
let g:tagbar_autofocus = 1
let g:tagbar_type_ruby = {
\ 'kinds' : [
\ 'm:modules',
\ 'c:classes',
\ 'd:describes',
\ 'C:contexts',
\ 'f:methods',
\ 'F:singleton methods'
\ ]
\ }
"*****************************************************************************
"" Terminal Emulation
"*****************************************************************************
" terminal emulation
nnoremap <silent> <leader>sh :terminal<CR>
"Open a terminal in a new tab
map <silent> <M-C-N> :tabnew <bar> :terminal<CR>
"*****************************************************************************
"" textobj-rubyblock
"*****************************************************************************
runtime macros/matchit.vim
set nocompatible
if has("autocmd")
filetype indent plugin on
endif
let g:textobj_ruby_more_mappings = 1
"*****************************************************************************
"" Typescript
"*****************************************************************************
" typescript
let g:yats_host_keyword = 1
"*****************************************************************************
"" UltiSnips
"*****************************************************************************
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
" let g:UltiSnipsExpandTrigger="<tab>"
" let g:UltiSnipsJumpForwardTrigger="<c-b>"
" let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" let g:UltiSnipsEditSplit="vertical"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
let g:UltiSnipsEditSplit="vertical"
" let g:UltiSnipsSnippetDirectories=["UltiSnips", "myUltiSnips"]
"*****************************************************************************
"" vim-airline
"*****************************************************************************
let g:airline_theme = 'powerlineish'
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline#extensions#tagbar#enabled = 1
let g:airline_skip_empty_sections = 1
"python
let g:airline#extensions#virtualenv#enabled = 1
"*****************************************************************************
"" Vimroom
"*****************************************************************************
"Vimroom
let g:goyo_width=100
let g:goyo_margin_top = 2
let g:goyo_margin_bottom = 2
nnoremap <silent> <leader>z :Goyo<cr>
"*****************************************************************************
"" vim-ruby-doc
"*****************************************************************************
" For some reason this plugin doesn't work anymore,
" so I hacked together the same functionality, using its example.
" Replace 'firefox' with whatever command you need instead.
let g:ruby_doc_url_template="http://rubydoc.info/search/stdlib/core?q=%"
let g:rails_doc_url_template="http://api.rubyonrails.org/?q=%"
let g:rspec_doc_url_template='https://www.relishapp.com/rspec/search?query=%'
function! AnyRDoc(url_template)
if &ft =~ "ruby"
else
return
endif
let s:wordUnderCursor = expand("<cword>")
let s:url = substitute(a:url_template, "%", s:wordUnderCursor, "g")
let s:cmd = "!firefox \"" . s:url . "\""
execute s:cmd
endfunction
map RB :call AnyRDoc(ruby_doc_url_template)<CR>
map RR :call AnyRDoc(rails_doc_url_template)<CR>
map RS :call AnyRDoc(rspec_doc_url_template)<CR>
let g:vimwiki_list = [{'path': '~/Development/PanhandleDoorDocuments/', 'path_html': '~/public_html/'}]
"*****************************************************************************
"" visualbell
"*****************************************************************************
" Disable visualbell
set noerrorbells visualbell t_vb=
if has('autocmd')
autocmd GUIEnter * set visualbell t_vb=
endif
"*****************************************************************************
"" Visual Mode
"*****************************************************************************
"" Vmap for maintain Visual Mode after shifting > and <
vmap < <gv
vmap > >gv
"" Move visual block
" vnoremap J :m '>+1<CR>gv=gv
" vnoremap K :m '<-2<CR>gv=gv
"*****************************************************************************
"" Visual Settings
"*****************************************************************************
syntax on
set ruler
set number
let no_buffers_menu=1
set mousemodel=popup
set t_Co=256
set guioptions=egmrti
set gfn=Monospace\ 10
if has("gui_running")
if has("gui_mac") || has("gui_macvim")
set guifont=Menlo:h12
set transparency=7
endif
else
let g:CSApprox_loaded = 1
" IndentLine
let g:indentLine_enabled = 1
let g:indentLine_concealcursor = 0
let g:indentLine_char = '┆'
let g:indentLine_faster = 1
endif
"" Disable the blinking cursor.
set gcr+=a:blinkon0
set scrolloff=3
"" Status bar
set laststatus=2
"" Use modeline overrides
set modeline
set modelines=10
set title
set titleold="Terminal"
set titlestring=%F
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
if exists("*fugitive#statusline")
set statusline+=%{fugitive#statusline()}
endif
"*****************************************************************************
"" XML
"*****************************************************************************
function! DoFormatXML()
:%s/></>\r</g
:0
=:$
endfunction
com! FormatXML call DoFormatXML()
"*****************************************************************************
"" YAML
"*****************************************************************************
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
set foldlevelstart=20
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'
" let g:ale_lint_on_text_changed = 'never'
"*****************************************************************************
"" CPC NEOVIM CONFIGURATION
"" Maintainer: Alexander JK Garber
"*****************************************************************************
"*****************************************************************************
"" Vim-PLug core
"*****************************************************************************
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
let g:vim_bootstrap_langs = "go,haskell,html,javascript,lisp,python,ruby,typescript"
let g:vim_bootstrap_editor = "nvim" " nvim or 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
" Required:
call plug#begin(expand('~/.config/nvim/plugged'))
"****************************************************************************
"" Project
"****************************************************************************
" Functional Start Screen
" Plug 'mhinz/vim-startify'
" Treeview file browser in VIM
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
" Plug 'MarSoft/nerdtree-grep-plugin'
" Status bar above and below
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Show changed lines in gutter
Plug 'airblade/vim-gitgutter'
" Search for strings in files
Plug 'vim-scripts/grep.vim'
"GVim-only colour schemes
Plug 'vim-scripts/CSApprox'
" Fuzzy file search
if isdirectory('/usr/local/opt/fzf')
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
else
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
endif
let g:make = 'gmake'
if exists('make')
let g:make = 'make'
endif
" Find and Replace
Plug 'brooth/far.vim'
" Interactive command execution
Plug 'Shougo/vimproc.vim', {'do': g:make}
"" Vim-Session
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'
" ctags
" Plug 'ludovicchabant/vim-gutentags'
" Plug 'craigemery/vim-autotag'
"codequery
" Plug 'Shougo/unite.vim'
" Plug 'devjoe/vim-codequery'
"grep replace
Plug 'skwp/greplace.vim'
"view images
Plug 'ashisha/image.vim'
"Reload files changed on disk
Plug 'djoshea/vim-autoread'
" Fountain plugin
Plug 'kblin/vim-fountain'
" Close buffers
Plug 'Asheq/close-buffers.vim'
" Conquer of Code (Autocomplete)
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Autosave sessions
Plug 'tpope/vim-obsession'
"Use Vim in the browser
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
"****************************************************************************
"" Editor (NORMAL MODE ONLY)
"****************************************************************************
" Comment out lines with gcc or gc in visual mode
Plug 'tpope/vim-commentary'
" Tag viewer for class and method definitions
Plug 'majutsushi/tagbar'
" Display thin vertical lines for indentations
Plug 'Yggdroot/indentLine'
" Repeat a plug-in command
Plug 'tpope/vim-repeat'
" Improved clipping of text
Plug 'svermeulen/vim-easyclip'
"Replace double quotes, single quotes, etc
Plug 'tpope/vim-surround'
"Split single line to multiline and visa versa
Plug 'AndrewRadev/splitjoin.vim'
"Word Motion
" Plug 'chaoren/vim-wordmotion'
"Resize Windows
Plug 'simeji/winresizer'
"****************************************************************************
"" Editor (INSERT MODE ONLY)
"****************************************************************************
"Autocomplete
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'ervandew/supertab'
"Snippets
Plug 'sirver/UltiSnips'
Plug 'honza/vim-snippets'
" Autocomplete brackets, quotes, etc.
Plug 'Raimondi/delimitMate'
"Markdown tables
Plug 'dhruvasagar/vim-table-mode'
"
"Pairs of handy bracket mappings
Plug 'tpope/vim-unimpaired'
"Horizontal navigation"
Plug 'unblevable/quick-scope'
"Automatic bullet and numbered lists
Plug 'dkarter/bullets.vim'
"Automatic newline and indentation between brackets
Plug 'jiangmiao/auto-pairs'
"Merge git conflicts
Plug 'christoomey/vim-conflicted'
"****************************************************************************
"" Editor (VISUAL MODE ONLY)
"****************************************************************************
"Select a ruby block in VISUAL mode
Plug 'nelstrom/vim-textobj-rubyblock'
" dependency of vim-textobj-rubyblock
Plug 'kana/vim-textobj-user'
"Scratch buffer
" Plug 'mtth/scratch.vim'
"****************************************************************************
"" Editor (COMBINED MODES)
"****************************************************************************
"Make Goyo even nicer
Plug 'amix/vim-zenroom2'
"Code linting
Plug 'dense-analysis/ale'
Plug 'prettier/vim-prettier'
"OrgMode for VIM
Plug 'jceb/vim-orgmode'
"Atomesque coloures
Plug 'joshdick/onedark.vim'
"Distraction-free editing
Plug 'junegunn/goyo.vim'
"Markdown preview
" Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
" Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
" Plug 'iamcco/markdown-preview.nvim'
Plug 'suan/vim-instant-markdown', {'for': 'markdown', 'do': 'yarn install'}
"Floating Terminal
Plug 'voldikss/vim-floaterm'
"Cucumber syntax highlighting
Plug 'barboza/vim-cucumber-string-highlight'
""****************************************************************************
"" Version Control
"****************************************************************************
" Git wrapper
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb' " required by fugitive to :Gbrowse
" GraphQL syntax highlighting
Plug 'jparise/vim-graphql'
"***************************************************************************
"" Ruby and Rails
"***************************************************************************
"Refactor
Plug 'ecomba/vim-ruby-refactoring'
Plug 'thoughtbot/vim-rspec'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-cucumber'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-rake'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-rbenv'
Plug 'thoughtbot/vim-rspec'
Plug 'vim-ruby/vim-ruby'
"Ruby/Rails/RSpec documentation
" Plug 'lucapette/vim-ruby-doc'
" Toggle Ruby do/end and {}
Plug 'jgdavey/vim-blockle'
"***************************************************************************
"" Other Languages
"***************************************************************************
" go
"" Go Lang Bundle
Plug 'fatih/vim-go', {'do': ':GoInstallBinaries'}
" haskell
"" Haskell Bundle
Plug 'eagletmt/neco-ghc'
Plug 'dag/vim2hs'
Plug 'pbrisbin/vim-syntax-shakespeare'
" html
"" HTML Bundle
Plug 'hail2u/vim-css3-syntax'
" Plug 'gorodinskiy/vim-coloresque'
Plug 'tpope/vim-haml'
Plug 'mattn/emmet-vim'
Plug 'zeekay/vim-beautify'
" javascript
"" Javascript Bundle
Plug 'jelera/vim-javascript-syntax'
" lisp
"" Lisp Bundle
Plug 'vim-scripts/slimv.vim'
" python
"" Python Bundle
Plug 'davidhalter/jedi-vim'
Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'}
" typescript
Plug 'leafgarland/typescript-vim'
Plug 'HerringtonDarkholme/yats.vim'
"VimBeGood (Primeagen)
" Plug 'ThePrimeagen/vim-be-good', {'do': './install.sh'}
"FISH Scripting
Plug 'dag/vim-fish'
"Writing Tools
Plug 'preservim/vim-pencil'
Plug 'dbmrq/vim-ditto'
Plug 'honza/writer.vim'
Plug 'mattn/vim-metarw-gdrive'
" Plug 'vimwiki/vimwiki'
Plug 'vim-latex/vim-latex'
"*****************************************************************************
call plug#end()
"***************************************************************************
"" Core VIM Keybindings
"***************************************************************************"
" Map leader to ,
let mapleader=','
"map LocalLeader to \\
let maplocalleader = "\\"
"Left (h) => [h]
noremap h h
"Up (j) => [t]
noremap t gj
"Down (k) => [n]
noremap n gk
"Right (l) => [s]
noremap s l
"End of line ($) => [-]
noremap - $
"Start of line (^) => [_]
noremap _ ^
"Jump to letter before (t) => [j]
noremap k t
"Sentences
noremap $ s
"m is shadowed by easyclip plugin
noremap gm m
" j/J moves between search mappings
nnoremap j n
nnoremap J N
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
" nnoremap j nzzzv
" nnoremap J Nzzzv
"Move text down
nnoremap <A-t> :m .+1<CR>==
inoremap <A-t> <Esc>:m .+1<CR>==gi
vnoremap <A-t> :m '>+1<CR>gv=gv
"Move text up
nnoremap <A-n> :m .-2<CR>==
inoremap <A-n> <Esc>:m .-2<CR>==gi
vnoremap <A-n> :m '<-2<CR>gv=gv
"*****************************************************************************
"" Mappings
"*****************************************************************************
"" Split
noremap <Leader>h :<C-u>split<CR>
" New buffer rather than the current file
noremap <Leader>v :<C-u>vnew<CR>
" Current file rather than a new buffer
" noremap <Leader>v :<C-u>vsplit<CR>
"*****************************************************************************
"Customised VIM
"*****************************************************************************
"Show how many lines yanked, inter alia
set report=0
"Hybrid line numbers
:set number relativenumber
:augroup numbertoggle
: autocmd!
: autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
: autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
:augroup END
"More natural movement in INSERT mode
behave mswin
"*****************************************************************************
"" Custom Bindings
"*****************************************************************************
"Fix indentation for the whole file
nnoremap <F7> gg=G<C-o><C-o>
" Bind F8 to fixing problems with ALE
nmap <F8> <Plug>(ale_fix)
"Force filetype 'yaml' for yml files
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml foldmethod=manual
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" autocmd BufNewFile,BufRead *.yml set ft=yaml
"Stop line wrap from breaking words
set linebreak
"Skip out of brackets
inoremap <C-e> <C-o>A
"Replace all
nnoremap S :%s///g<Left><Left><Left>
"Jump to next occurrence in INSERT mode
imap <C-j> <Esc>jcaw
"Replace all within a visual selection
" vnoremap S :s/\%V//g<Left><Left><Left>
"Ctrl-A for select all
" vnnoremap <C-a> ggVG
"Replace all matching strings in visual selection
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
" Close all hidden buffers
nnoremap <silent> <C-q> :Bdelete menu<CR>
function! ALEFixFast()
syntax off
exec "ALEFix"
syntax on
endfunction
"Save file, even if no changes
nor <silent> <Leader>w :w<CR>
vnoremap <silent> <C-w> <C-C>:update<CR>
"Close all buffers and quit Neovim
noremap <Leader>' :qall<CR>
"*****************************************************************************
"" Abbreviations
"*****************************************************************************
"" no one is really happy until you have this shortcuts
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall
"*****************************************************************************
"" ALE
"*****************************************************************************
" LINTERS
let g:ale_linters = {
\ 'gql': ['prettier'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\ 'vim': ['vint'],
\}
function! SettingsTurnOff()
"Turns syntax off only in current buffer
exec "syntax clear"
" exec "set nocursorcolumn"
" exec "set nocursorline"
" exec "set norelativenumber"
endfunction
function! SettingsTurnOn()
exec "syntax on"
" exec "set number relativenumber"
exec "AirlineRefresh"
endfunction
augroup YourGroup
autocmd!
autocmd User ALEFixPre call SettingsTurnOff()
autocmd User ALEFixPost call SettingsTurnOn()
augroup END
" FIXERS
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\}
let g:ale_lint_on_enter = 1
let g:ale_completion_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %(code): %%s [%severity%]'
let g:airline#extensions#ale#enabled = 1
" let g:ale_ruby_rubocop_executable = 'rubocop-daemon exec -- --auto-correct'
" set omnifunc=ale#completion#OmniFunc
"*****************************************************************************
"" Autocmd Rules, Functions
"*****************************************************************************
"" Functions
if !exists('*s:setupWrapping')
function s:setupWrapping()
set wrap
set wm=2
set textwidth=80
endfunction
endif
"*****************************************************************************
"" Autocmd Rules
"*****************************************************************************
"" The PC is fast enough, do syntax highlight syncing from start unless 200 lines
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=200
augroup END
"" Remember cursor position
augroup vimrc-remember-cursor-position
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
"" txt
augroup vimrc-wrapping
autocmd!
autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
augroup END
"" make/cmake
augroup vimrc-make-cmake
autocmd!
autocmd FileType make setlocal noexpandtab
autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
augroup END
set autoread
"*****************************************************************************
"" AUTO PAIRS
"*****************************************************************************
" Jump outside '"({
if !exists('g:AutoPairsShortcutJump')
let g:AutoPairsShortcutJump = '<C-l>'
endif
"*****************************************************************************
"" Buffers, Tabs, Windows
"*****************************************************************************
"" Buffer nav
noremap <leader>x :bn<CR>
"" Close buffer
noremap <leader>c :bd<CR>
"" Enable hidden buffers
" set hidden
"" Switching windows
noremap <C-h> <C-w>h
noremap <C-t> <C-w>j
noremap <C-n> <C-w>k
noremap <C-s> <C-w>l
"" Tabs
nnoremap <Tab> gt
nnoremap <S-Tab> gT
nnoremap <silent> <S-t> :tabnew<CR>
"Scratch buffer
function! Scratch()
tabnew
noswapfile hide enew
setlocal buftype=nofile
setlocal bufhidden=hide
"setlocal nobuflisted
"lcd ~
file scratch
endfunction
"*****************************************************************************
"" COC
"*****************************************************************************
" 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
" let g:coc_global_extensions = ['coc-solargraph']
"*****************************************************************************
"" Copy/Paste/Cut
"*****************************************************************************
if has('unnamedplus')
set clipboard=unnamed,unnamedplus
endif
noremap YY "+y<CR>
noremap <leader>p "+gP<CR>
noremap XX "+x<CR>
if has('macunix')
" pbcopy for OSX copy/paste
vmap <C-x> :!pbcopy<CR>
vmap <C-c> :w !pbcopy<CR><CR>
endif
"*****************************************************************************
"" deoplete
"*****************************************************************************
""deoplete
let g:deoplete#enable_at_startup = 1
let g:auto_complete_popup = "manual"
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ deoplete#mappings#manual_complete()
function! s:check_back_space() abort "{{{
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction"}}}
"*****************************************************************************
"" neosnippet
"*****************************************************************************
" " Plugin key-mappings.
" " Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <C-k> <Plug>(neosnippet_expand_or_jump)
" smap <C-k> <Plug>(neosnippet_expand_or_jump)
" xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
" if has('conceal')
" set conceallevel=2 concealcursor=niv
" endif
" " To use Honza's Vim Snippets
" let g:neosnippet#snippets_directory='~/.config/nvim/plugged/vim-snippets/snippets'
"*****************************************************************************
"" Encoding
"*****************************************************************************
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
let g:far#enable_undo=1
"*****************************************************************************
"" fish
"*****************************************************************************
if &shell =~# 'fish$'
set shell=sh
endif
"*****************************************************************************
"" fzf
"*****************************************************************************
set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
let $FZF_DEFAULT_COMMAND = "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'dist/**' -prune -o -type f -print -o -type l -print 2> /dev/null"
" nnoremap <silent> <leader>b :Buffers<CR>
nnoremap <silent> <leader>e :FZF -m<CR>
"Recovery commands from history through FZF
nmap <leader>y :History:<CR>
"NOTE: To open a file in a new tab CTRL-V, CTRL-X, or CTRL-T
"*****************************************************************************
"" General Settings
"*****************************************************************************
"Use `onedark` colour scheme
" colorscheme onedark
colo onedark
"Syntax highlighting from start unless 1000 lines (instead of 200)
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=1000
augroup END
"Refresh file when changed on disk
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI *
\ if mode() !~ '\v(c|r.?|!|t)' && getcmdwintype() == '' | checktime | endif
"Autowrite
set autowriteall
" :set tabstop=2
" :set shiftwidth=2
" :set expandtab
" Folding
set fdm=syntax
set nofoldenable
" set foldlevel=0
" Built-in Neovim autocomplete
cnoremap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
"NERDTree can modify files
set modifiable
"Add Cucumber filetype detection
au BufRead,BufNewFile *.cucumber set filetype=cucumber
"Various completion plugins require this
filetype plugin on
"Omni completion
" set omnifunc=syntaxcomplete#Complete
"Spell check
nnoremap <F10> :set spell! spelllang=en_gb,lt,fr,he!<CR>
"Center screen when going into INSERT mode
" autocmd InsertEnter * norm zz
"Thin line cursor in INSERT mode
highlight Cursor guifg=white guibg=black
highlight iCursor guifg=white guibg=steelblue
set guicursor=n-v-c:block-Cursor
set guicursor=i:ver25-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait10
"Highlight current line
autocmd InsertEnter,InsertLeave * set cul!
"Auotmatically split to the right
set splitright
"*****************************************************************************
"" Git
"*****************************************************************************
noremap <Leader>ga :Gwrite<CR>
noremap <Leader>gc :Gcommit<CR>
noremap <Leader>gsh :Gpush<CR>
noremap <Leader>gll :Gpull<CR>
noremap <Leader>gs :Gstatus<CR>
noremap <Leader>gb :Gblame<CR>
noremap <Leader>gd :Gvdiff<CR>
noremap <Leader>gr :Gremove<CR>
"" Open current line on GitHub
nnoremap <Leader>o :.Gbrowse<CR>
set diffopt+=vertical
"*****************************************************************************
"" Go Language
"*****************************************************************************
" autocmd BufWritePost *.go !go test
"*****************************************************************************
"" grep.vim
"*****************************************************************************
" grep.vim
nnoremap <silent> <leader>f :Rgrep<CR>
let Grep_Default_Options = '-IR'
let Grep_Skip_Files = '*.log *.db'
let Grep_Skip_Dirs = '.git node_modules'
"*****************************************************************************
"" HTML
"*****************************************************************************
" for html files, 2 spaces
autocmd Filetype html setlocal ts=2 sw=2 expandtab
"View HTML Text
function! ViewHtmlText(url)
if !empty(a:url)
new
setlocal buftype=nofile bufhidden=hide noswapfile
execute 'r !elinks ' . a:url . ' -dump -dump-width ' . winwidth(0)
1d
endif
endfunction
" Save and view text for current html file.
nnoremap <Leader>H :update<Bar>call ViewHtmlText(expand('%:p'))<CR>
" " View text for visually selected url.
vnoremap <Leader>h y:call ViewHtmlText(@*)<CR>
" View text for URL from clipboard.
" On Linux, use @* for current selection or @+ for text in clipboard.
nnoremap <Leader>h :call ViewHtmlText(@+)<CR>
"*****************************************************************************
"" Emmet
"*****************************************************************************
" let g:user_emmet_install_global = 0
" autocmd FileType html,css,erb EmmetInstall
let g:user_emmet_leader_key=','
"*****************************************************************************
"" Indentations, Tabs, Whitespaces
"*****************************************************************************
"" Fix backspace indent
set backspace=indent,eol,start
"" Tabs. May be overridden by autocmd rules
set tabstop=2
set softtabstop=0
set shiftwidth=2
set expandtab
" remove trailing whitespaces
command! FixWhitespace :%s/\s\+$//e
"Fix indentation for the whole file
" nnoremap <F7> gg=G<C-o><C-o>
"*****************************************************************************
"" JavaScript
"*****************************************************************************
" javascript
let g:javascript_enable_domhtmlcss = 1
" vim-javascript
augroup vimrc-javascript
autocmd!
autocmd FileType javascript setl tabstop=4|setl shiftwidth=4|setl expandtab softtabstop=4
augroup END
"*****************************************************************************
"" LanguageClient-Neovim
"*****************************************************************************
" Tell the language client to use the default IP and port
" that Solargraph runs on
" let g:LanguageClient_serverCommands = {
" \ 'ruby': ['tcp://localhost:7658']
" \ }
" Don't send a stop signal to the server when exiting vim.
" This is optional, but I don't like having to restart Solargraph
" every time I restart vim.
" let g:LanguageClient_autoStop = 0
" Configure ruby omni-completion to use the language client:
" autocmd FileType ruby setlocal omnifunc=LanguageClient#complete
" Required for operations modifying multiple buffers like rename.
" set hidden
" let g:LanguageClient_serverCommands = {
" \ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
" \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
" \ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
" \ 'python': ['/usr/local/bin/pyls'],
" \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'],
" \ }
" nnoremap <F5> :call LanguageClient_contextMenu()<CR>
" " Or map each action separately
" nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
" nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
" nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
"*****************************************************************************
"" Macros
"*****************************************************************************
nnoremap <leader>gcr If<esc>A # rubocop:disable RSpec/Focus<esc>
nnoremap <leader>sal gg<esc>O$seeds_already_loaded = true<esc><C-o>
nnoremap <leader>gms gg<esc>O$minimal_seeds = true<esc><C-o>
"*****************************************************************************
"" Markdown
"*****************************************************************************
"Markdown plugin
" filetype plugin on
let g:vim_markdown_conceal = 0
let g:vim_markdown_conceal_code_blocks = 0
"Uncomment to override defaults:
"let g:instant_markdown_slow = 1
"let g:instant_markdown_autostart = 0
"let g:instant_markdown_open_to_the_world = 1
"let g:instant_markdown_allow_unsafe_content = 1
"let g:instant_markdown_allow_external_content = 0
"let g:instant_markdown_mathjax = 1
"let g:instant_markdown_logfile = '/tmp/instant_markdown.log'
"let g:instant_markdown_autoscroll = 0
"let g:instant_markdown_port = 8888
"let g:instant_markdown_python = 1
"MarkdownPreview
" set to 1, nvim will open the preview window after entering the markdown buffer
" default: 0
let g:mkdp_auto_start = 1
" set to 1, the nvim will auto close current preview window when change
" from markdown buffer to another buffer
" default: 1
let g:mkdp_auto_close = 1
" set to 1, the vim will refresh markdown when save the buffer or
" leave from insert mode, default 0 is auto refresh markdown as you edit or
" move the cursor
" default: 0
let g:mkdp_refresh_slow = 0
" set to 1, the MarkdownPreview command can be use for all files,
" by default it can be use in markdown file
" default: 0
let g:mkdp_command_for_global = 0
" set to 1, preview server available to others in your network
" by default, the server listens on localhost (127.0.0.1)
" default: 0
let g:mkdp_open_to_the_world = 0
" use custom IP to open preview page
" useful when you work in remote vim and preview on local browser
" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9
" default empty
let g:mkdp_open_ip = ''
" specify browser to open preview page
" default: ''
let g:mkdp_browser = ''
" set to 1, echo preview page url in command line when open preview page
" default is 0
let g:mkdp_echo_preview_url = 0
" a custom vim function name to open preview page
" this function will receive url as param
" default is empty
let g:mkdp_browserfunc = ''
" options for markdown render
" mkit: markdown-it options for render
" katex: katex options for math
" uml: markdown-it-plantuml options
" maid: mermaid options
" disable_sync_scroll: if disable sync scroll, default 0
" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle'
" middle: mean the cursor position alway show at the middle of the preview page
" top: mean the vim top viewport alway show at the top of the preview page
" relative: mean the cursor position alway show at the relative positon of the preview page
" hide_yaml_meta: if hide yaml metadata, default is 1
" sequence_diagrams: js-sequence-diagrams options
" content_editable: if enable content editable for preview page, default: v:false
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1,
\ 'sequence_diagrams': {},
\ 'flowchart_diagrams': {},
\ 'content_editable': v:false
\ }
" use a custom markdown style must be absolute path
" like '/Users/username/markdown.css' or expand('~/markdown.css')
let g:mkdp_markdown_css = ''
" use a custom highlight style must absolute path
" like '/Users/username/highlight.css' or expand('~/highlight.css')
let g:mkdp_highlight_css = ''
" use a custom port to start server or random for empty
let g:mkdp_port = ''
" preview page title
" ${name} will be replace with the file name
let g:mkdp_page_title = '「${name}」'
"*****************************************************************************
"" NERDTree
"*****************************************************************************
"" NERDTree configuration
let g:NERDTreeChDirMode=2
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let g:NERDTreeShowBookmarks=1
let g:nerdtree_tabs_focus_on_files=1
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
let g:NERDTreeWinSize = 50
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
nnoremap <silent> <F2> :NERDTreeFind<CR>
nnoremap <silent> <F3> :NERDTreeToggle<CR>
let g:NERDTreeMapOpenInTab = "l"
"Close NERDTree when you open a file
let NERDTreeQuitOnOpen = 1
"Prettify NERDTree
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
" autocmd FileType nerdtree setlocal noreadonly
"*****************************************************************************
"" polyglot
"*****************************************************************************
" Syntax highlight
" Default highlight is better than polyglot
let g:polyglot_disabled = ['python']
let python_highlight_all = 1
"*****************************************************************************
"" Python
"*****************************************************************************
" vim-python
augroup vimrc-python
autocmd!
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 colorcolumn=79
\ formatoptions+=croq softtabstop=4
\ cinwords=if,elif,else,for,while,try,except,finally,def,class,with
augroup END
"*****************************************************************************
"" jedi-vim
"*****************************************************************************
let g:jedi#popup_on_dot = 0
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_definitions_command = "<leader>d"
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#rename_command = "<leader>r"
let g:jedi#show_call_signatures = "0"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#smart_auto_mappings = 0
"*****************************************************************************
"" ripgrep
"*****************************************************************************
if executable('rg')
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
set grepprg=rg\ --vimgrep
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
endif
"*****************************************************************************
"" rspec.vim
"*****************************************************************************
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
"Prepend `bundle exec`
let g:rspec_command = "!bundle exec rspec {spec}"
"*****************************************************************************
"" Ruby
"*****************************************************************************
"Omnicomplete
let g:ruby_host_prog = '~/.rbenv/shims/neovim-ruby-host'
let g:ruby_path = system('echo $HOME/.rbenv/shims')
" ruby
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
augroup vimrc-ruby
autocmd!
autocmd BufNewFile,BufRead *.rb,*.rbw,*.gemspec setlocal filetype=ruby
autocmd FileType ruby set tabstop=2|set shiftwidth=2|set expandtab softtabstop=2
augroup END
" For ruby refactory
if has('nvim')
runtime! macros/matchit.vim
else
packadd! matchit
endif
" Ruby refactory
nnoremap <leader>rap :RAddParameter<cr>
nnoremap <leader>rcpc :RConvertPostConditional<cr>
nnoremap <leader>rel :RExtractLet<cr>
vnoremap <leader>rec :RExtractConstant<cr>
vnoremap <leader>relv :RExtractLocalVariable<cr>
nnoremap <leader>rit :RInlineTemp<cr>
vnoremap <leader>rrlv :RRenameLocalVariable<cr>
vnoremap <leader>rriv :RRenameInstanceVariable<cr>
vnoremap <leader>rem :RExtractMethod<cr>
"Run RSpec in Tmux
" map <Leader>rt :w<cr>:call RunCurrentTest('!ts be rspec')<CR>
" Thoughtbot Vim-RSpec
let g:rspec_command = "Dispatch bundle exec rspec {spec}"
" let g:rspec_command = "!bundle exec rspec {spec}"
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
" map <LocalLeader>s :e db/schema.rb<CR>
"*****************************************************************************
"" Search
"*****************************************************************************
"" Clean search (highlight)
nnoremap <silent> <leader><space> :noh<cr>
"" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
set fileformats=unix,dos,mac
if exists('$SHELL')
set shell=$SHELL
else
set shell=/bin/sh
endif
"Search for visually selected text
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
"*****************************************************************************
"" Session Management
"*****************************************************************************
nnoremap <leader>so :OpenSession<Space>
nnoremap <leader>ss :SaveSession<Space>
nnoremap <leader>sd :DeleteSession<CR>
nnoremap <leader>sc :CloseSession<CR>
let g:session_directory = "~/.config/nvim/session"
let g:session_autoload = "no"
let g:session_autosave = "yes"
let g:session_autosave_periodic = 1
let g:session_command_aliases = 1
let g:session_autosave_silent = 1
"*****************************************************************************
"" The Silver Searcher
"*****************************************************************************
if executable('ag')
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
set grepprg=ag\ --nogroup\ --nocolor
endif
let g:startify_session_dir = '~/.config/nvim/session'
let g:startify_lists = [
\ { 'type': 'files', 'header': [' Files'] },
\ { 'type': 'dir', 'header': [' Current Directory '. getcwd()] },
\ { 'type': 'sessions', 'header': [' Sessions'] },
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
\ ]
let g:startify_bookmarks = [
\ { 'i': '~/.config/nvim/init.vim' },
\ '~/Development/inspiregroup/chameleon/creator/services/creator-backend',
\ '~/Development/publish/clockworkpc.github.io',
\ '~/Development/inspiregroup/chameleon/collect',
\ ]
let g:startify_session_autoload = 1
let g:startify_fortune_use_unicode = 1
let g:startify_session_persistence = 1
let g:startify_enable_special = 0
"*****************************************************************************
"" Tagbar
"*****************************************************************************
nmap <silent> <F4> :TagbarToggle<CR>
let g:tagbar_autofocus = 1
let g:tagbar_type_ruby = {
\ 'kinds' : [
\ 'm:modules',
\ 'c:classes',
\ 'd:describes',
\ 'C:contexts',
\ 'f:methods',
\ 'F:singleton methods'
\ ]
\ }
"*****************************************************************************
"" Terminal Emulation
"*****************************************************************************
" terminal emulation
nnoremap <silent> <leader>sh :terminal<CR>
"Open a terminal in a new tab
map <silent> <M-C-N> :tabnew <bar> :terminal<CR>
"*****************************************************************************
"" textobj-rubyblock
"*****************************************************************************
runtime macros/matchit.vim
set nocompatible
if has("autocmd")
filetype indent plugin on
endif
let g:textobj_ruby_more_mappings = 1
"*****************************************************************************
"" Typescript
"*****************************************************************************
" typescript
let g:yats_host_keyword = 1
"*****************************************************************************
"" UltiSnips
"*****************************************************************************
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
" let g:UltiSnipsExpandTrigger="<tab>"
" let g:UltiSnipsJumpForwardTrigger="<c-b>"
" let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" let g:UltiSnipsEditSplit="vertical"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
let g:UltiSnipsEditSplit="vertical"
" let g:UltiSnipsSnippetDirectories=["UltiSnips", "myUltiSnips"]
"*****************************************************************************
"" vim-airline
"*****************************************************************************
let g:airline_theme = 'powerlineish'
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline#extensions#tagbar#enabled = 1
let g:airline_skip_empty_sections = 1
"python
let g:airline#extensions#virtualenv#enabled = 1
"*****************************************************************************
"" Vimroom
"*****************************************************************************
"Vimroom
let g:goyo_width=100
let g:goyo_margin_top = 2
let g:goyo_margin_bottom = 2
nnoremap <silent> <leader>z :Goyo<cr>
"*****************************************************************************
"" vim-ruby-doc
"*****************************************************************************
" For some reason this plugin doesn't work anymore,
" so I hacked together the same functionality, using its example.
" Replace 'firefox' with whatever command you need instead.
let g:ruby_doc_url_template="http://rubydoc.info/search/stdlib/core?q=%"
let g:rails_doc_url_template="http://api.rubyonrails.org/?q=%"
let g:rspec_doc_url_template='https://www.relishapp.com/rspec/search?query=%'
function! AnyRDoc(url_template)
if &ft =~ "ruby"
else
return
endif
let s:wordUnderCursor = expand("<cword>")
let s:url = substitute(a:url_template, "%", s:wordUnderCursor, "g")
let s:cmd = "!firefox \"" . s:url . "\""
execute s:cmd
endfunction
map RB :call AnyRDoc(ruby_doc_url_template)<CR>
map RR :call AnyRDoc(rails_doc_url_template)<CR>
map RS :call AnyRDoc(rspec_doc_url_template)<CR>
let g:vimwiki_list = [{'path': '~/Development/PanhandleDoorDocuments/', 'path_html': '~/public_html/'}]
"*****************************************************************************
"" visualbell
"*****************************************************************************
" Disable visualbell
set noerrorbells visualbell t_vb=
if has('autocmd')
autocmd GUIEnter * set visualbell t_vb=
endif
"*****************************************************************************
"" Visual Mode
"*****************************************************************************
"" Vmap for maintain Visual Mode after shifting > and <
vmap < <gv
vmap > >gv
"" Move visual block
" vnoremap J :m '>+1<CR>gv=gv
" vnoremap K :m '<-2<CR>gv=gv
"*****************************************************************************
"" Visual Settings
"*****************************************************************************
syntax on
set ruler
set number
let no_buffers_menu=1
set mousemodel=popup
set t_Co=256
set guioptions=egmrti
set gfn=Monospace\ 10
if has("gui_running")
if has("gui_mac") || has("gui_macvim")
set guifont=Menlo:h12
set transparency=7
endif
else
let g:CSApprox_loaded = 1
" IndentLine
let g:indentLine_enabled = 1
let g:indentLine_concealcursor = 0
let g:indentLine_char = '┆'
let g:indentLine_faster = 1
endif
"" Disable the blinking cursor.
set gcr+=a:blinkon0
set scrolloff=3
"" Status bar
set laststatus=2
"" Use modeline overrides
set modeline
set modelines=10
set title
set titleold="Terminal"
set titlestring=%F
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
if exists("*fugitive#statusline")
set statusline+=%{fugitive#statusline()}
endif
"*****************************************************************************
"" XML
"*****************************************************************************
function! DoFormatXML()
:%s/></>\r</g
:0
=:$
endfunction
com! FormatXML call DoFormatXML()
"*****************************************************************************
"" YAML
"*****************************************************************************
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
set foldlevelstart=20
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'
" let g:ale_lint_on_text_changed = 'never'
"*****************************************************************************
"" CPC NEOVIM CONFIGURATION
"" Maintainer: Alexander JK Garber
"*****************************************************************************
"*****************************************************************************
"" Vim-PLug core
"*****************************************************************************
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
let g:vim_bootstrap_langs = "go,haskell,html,javascript,lisp,python,ruby,typescript"
let g:vim_bootstrap_editor = "nvim" " nvim or 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
" Required:
call plug#begin(expand('~/.config/nvim/plugged'))
"****************************************************************************
"" Project
"****************************************************************************
" Functional Start Screen
" Plug 'mhinz/vim-startify'
" Treeview file browser in VIM
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
" Plug 'MarSoft/nerdtree-grep-plugin'
" Status bar above and below
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Show changed lines in gutter
Plug 'airblade/vim-gitgutter'
" Search for strings in files
Plug 'vim-scripts/grep.vim'
"GVim-only colour schemes
Plug 'vim-scripts/CSApprox'
" Fuzzy file search
if isdirectory('/usr/local/opt/fzf')
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
else
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
endif
let g:make = 'gmake'
if exists('make')
let g:make = 'make'
endif
" Find and Replace
Plug 'brooth/far.vim'
" Interactive command execution
Plug 'Shougo/vimproc.vim', {'do': g:make}
"" Vim-Session
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'
" ctags
" Plug 'ludovicchabant/vim-gutentags'
" Plug 'craigemery/vim-autotag'
"codequery
" Plug 'Shougo/unite.vim'
" Plug 'devjoe/vim-codequery'
"grep replace
Plug 'skwp/greplace.vim'
"view images
Plug 'ashisha/image.vim'
"Reload files changed on disk
Plug 'djoshea/vim-autoread'
" Fountain plugin
Plug 'kblin/vim-fountain'
" Close buffers
Plug 'Asheq/close-buffers.vim'
" Conquer of Code (Autocomplete)
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Autosave sessions
Plug 'tpope/vim-obsession'
"Use Vim in the browser
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
"****************************************************************************
"" Editor (NORMAL MODE ONLY)
"****************************************************************************
" Comment out lines with gcc or gc in visual mode
Plug 'tpope/vim-commentary'
" Tag viewer for class and method definitions
Plug 'majutsushi/tagbar'
" Display thin vertical lines for indentations
Plug 'Yggdroot/indentLine'
" Repeat a plug-in command
Plug 'tpope/vim-repeat'
" Improved clipping of text
Plug 'svermeulen/vim-easyclip'
"Replace double quotes, single quotes, etc
Plug 'tpope/vim-surround'
"Split single line to multiline and visa versa
Plug 'AndrewRadev/splitjoin.vim'
"Word Motion
" Plug 'chaoren/vim-wordmotion'
"Resize Windows
Plug 'simeji/winresizer'
"****************************************************************************
"" Editor (INSERT MODE ONLY)
"****************************************************************************
"Autocomplete
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'ervandew/supertab'
"Snippets
Plug 'sirver/UltiSnips'
Plug 'honza/vim-snippets'
" Autocomplete brackets, quotes, etc.
Plug 'Raimondi/delimitMate'
"Markdown tables
Plug 'dhruvasagar/vim-table-mode'
"
"Pairs of handy bracket mappings
Plug 'tpope/vim-unimpaired'
"Horizontal navigation"
Plug 'unblevable/quick-scope'
"Automatic bullet and numbered lists
Plug 'dkarter/bullets.vim'
"Automatic newline and indentation between brackets
Plug 'jiangmiao/auto-pairs'
"Merge git conflicts
Plug 'christoomey/vim-conflicted'
"****************************************************************************
"" Editor (VISUAL MODE ONLY)
"****************************************************************************
"Select a ruby block in VISUAL mode
Plug 'nelstrom/vim-textobj-rubyblock'
" dependency of vim-textobj-rubyblock
Plug 'kana/vim-textobj-user'
"Scratch buffer
" Plug 'mtth/scratch.vim'
"****************************************************************************
"" Editor (COMBINED MODES)
"****************************************************************************
"Make Goyo even nicer
Plug 'amix/vim-zenroom2'
"Code linting
Plug 'dense-analysis/ale'
Plug 'prettier/vim-prettier'
"OrgMode for VIM
Plug 'jceb/vim-orgmode'
"Atomesque coloures
Plug 'joshdick/onedark.vim'
"Distraction-free editing
Plug 'junegunn/goyo.vim'
"Markdown preview
" Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
" Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
" Plug 'iamcco/markdown-preview.nvim'
Plug 'suan/vim-instant-markdown', {'for': 'markdown', 'do': 'yarn install'}
"Floating Terminal
Plug 'voldikss/vim-floaterm'
"Cucumber syntax highlighting
Plug 'barboza/vim-cucumber-string-highlight'
""****************************************************************************
"" Version Control
"****************************************************************************
" Git wrapper
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb' " required by fugitive to :Gbrowse
" GraphQL syntax highlighting
Plug 'jparise/vim-graphql'
"***************************************************************************
"" Ruby and Rails
"***************************************************************************
"Refactor
Plug 'ecomba/vim-ruby-refactoring'
Plug 'thoughtbot/vim-rspec'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-cucumber'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-rake'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-rbenv'
Plug 'thoughtbot/vim-rspec'
Plug 'vim-ruby/vim-ruby'
"Ruby/Rails/RSpec documentation
" Plug 'lucapette/vim-ruby-doc'
" Toggle Ruby do/end and {}
Plug 'jgdavey/vim-blockle'
"***************************************************************************
"" Other Languages
"***************************************************************************
" go
"" Go Lang Bundle
Plug 'fatih/vim-go', {'do': ':GoInstallBinaries'}
" haskell
"" Haskell Bundle
Plug 'eagletmt/neco-ghc'
Plug 'dag/vim2hs'
Plug 'pbrisbin/vim-syntax-shakespeare'
" html
"" HTML Bundle
Plug 'hail2u/vim-css3-syntax'
" Plug 'gorodinskiy/vim-coloresque'
Plug 'tpope/vim-haml'
Plug 'mattn/emmet-vim'
Plug 'zeekay/vim-beautify'
" javascript
"" Javascript Bundle
Plug 'jelera/vim-javascript-syntax'
" lisp
"" Lisp Bundle
Plug 'vim-scripts/slimv.vim'
" python
"" Python Bundle
Plug 'davidhalter/jedi-vim'
Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'}
" typescript
Plug 'leafgarland/typescript-vim'
Plug 'HerringtonDarkholme/yats.vim'
"VimBeGood (Primeagen)
" Plug 'ThePrimeagen/vim-be-good', {'do': './install.sh'}
"FISH Scripting
Plug 'dag/vim-fish'
"Writing Tools
Plug 'preservim/vim-pencil'
Plug 'dbmrq/vim-ditto'
Plug 'honza/writer.vim'
Plug 'mattn/vim-metarw-gdrive'
" Plug 'vimwiki/vimwiki'
Plug 'vim-latex/vim-latex'
"*****************************************************************************
call plug#end()
"***************************************************************************
"" Core VIM Keybindings
"***************************************************************************"
" Map leader to ,
let mapleader=','
"map LocalLeader to \\
let maplocalleader = "\\"
"Left (h) => [h]
noremap h h
"Up (j) => [t]
noremap t gj
"Down (k) => [n]
noremap n gk
"Right (l) => [s]
noremap s l
"End of line ($) => [-]
noremap - $
"Start of line (^) => [_]
noremap _ ^
"Jump to letter before (t) => [j]
noremap k t
"Sentences
noremap $ s
"m is shadowed by easyclip plugin
noremap gm m
" j/J moves between search mappings
nnoremap j n
nnoremap J N
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
" nnoremap j nzzzv
" nnoremap J Nzzzv
"Move text down
nnoremap <A-t> :m .+1<CR>==
inoremap <A-t> <Esc>:m .+1<CR>==gi
vnoremap <A-t> :m '>+1<CR>gv=gv
"Move text up
nnoremap <A-n> :m .-2<CR>==
inoremap <A-n> <Esc>:m .-2<CR>==gi
vnoremap <A-n> :m '<-2<CR>gv=gv
"*****************************************************************************
"" Mappings
"*****************************************************************************
"" Split
noremap <Leader>h :<C-u>split<CR>
" New buffer rather than the current file
noremap <Leader>v :<C-u>vnew<CR>
" Current file rather than a new buffer
" noremap <Leader>v :<C-u>vsplit<CR>
"*****************************************************************************
"Customised VIM
"*****************************************************************************
"Show how many lines yanked, inter alia
set report=0
"Hybrid line numbers
:set number relativenumber
:augroup numbertoggle
: autocmd!
: autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
: autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
:augroup END
"More natural movement in INSERT mode
behave mswin
"*****************************************************************************
"" Custom Bindings
"*****************************************************************************
"Fix indentation for the whole file
nnoremap <F7> gg=G<C-o><C-o>
" Bind F8 to fixing problems with ALE
nmap <F8> <Plug>(ale_fix)
"Force filetype 'yaml' for yml files
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml foldmethod=manual
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" autocmd BufNewFile,BufRead *.yml set ft=yaml
"Stop line wrap from breaking words
set linebreak
"Skip out of brackets
inoremap <C-e> <C-o>A
"Replace all
nnoremap S :%s///g<Left><Left><Left>
"Jump to next occurrence in INSERT mode
imap <C-j> <Esc>jcaw
"Replace all within a visual selection
" vnoremap S :s/\%V//g<Left><Left><Left>
"Ctrl-A for select all
" vnnoremap <C-a> ggVG
"Replace all matching strings in visual selection
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
" Close all hidden buffers
nnoremap <silent> <C-q> :Bdelete menu<CR>
function! ALEFixFast()
syntax off
exec "ALEFix"
syntax on
endfunction
"Save file, even if no changes
nor <silent> <Leader>w :w<CR>
vnoremap <silent> <C-w> <C-C>:update<CR>
"Close all buffers and quit Neovim
noremap <Leader>' :qall<CR>
"*****************************************************************************
"" Abbreviations
"*****************************************************************************
"" no one is really happy until you have this shortcuts
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall
"*****************************************************************************
"" ALE
"*****************************************************************************
" LINTERS
let g:ale_linters = {
\ 'gql': ['prettier'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\ 'vim': ['vint'],
\}
function! SettingsTurnOff()
"Turns syntax off only in current buffer
exec "syntax clear"
" exec "set nocursorcolumn"
" exec "set nocursorline"
" exec "set norelativenumber"
endfunction
function! SettingsTurnOn()
exec "syntax on"
" exec "set number relativenumber"
exec "AirlineRefresh"
endfunction
augroup YourGroup
autocmd!
autocmd User ALEFixPre call SettingsTurnOff()
autocmd User ALEFixPost call SettingsTurnOn()
augroup END
" FIXERS
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\}
let g:ale_lint_on_enter = 1
let g:ale_completion_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %(code): %%s [%severity%]'
let g:airline#extensions#ale#enabled = 1
" let g:ale_ruby_rubocop_executable = 'rubocop-daemon exec -- --auto-correct'
" set omnifunc=ale#completion#OmniFunc
"*****************************************************************************
"" Autocmd Rules, Functions
"*****************************************************************************
"" Functions
if !exists('*s:setupWrapping')
function s:setupWrapping()
set wrap
set wm=2
set textwidth=80
endfunction
endif
"*****************************************************************************
"" Autocmd Rules
"*****************************************************************************
"" The PC is fast enough, do syntax highlight syncing from start unless 200 lines
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=200
augroup END
"" Remember cursor position
augroup vimrc-remember-cursor-position
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
"" txt
augroup vimrc-wrapping
autocmd!
autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
augroup END
"" make/cmake
augroup vimrc-make-cmake
autocmd!
autocmd FileType make setlocal noexpandtab
autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
augroup END
set autoread
"*****************************************************************************
"" AUTO PAIRS
"*****************************************************************************
" Jump outside '"({
if !exists('g:AutoPairsShortcutJump')
let g:AutoPairsShortcutJump = '<C-l>'
endif
"*****************************************************************************
"" Buffers, Tabs, Windows
"*****************************************************************************
"" Buffer nav
noremap <leader>x :bn<CR>
"" Close buffer
noremap <leader>c :bd<CR>
"" Enable hidden buffers
" set hidden
"" Switching windows
noremap <C-h> <C-w>h
noremap <C-t> <C-w>j
noremap <C-n> <C-w>k
noremap <C-s> <C-w>l
"" Tabs
nnoremap <Tab> gt
nnoremap <S-Tab> gT
nnoremap <silent> <S-t> :tabnew<CR>
"Scratch buffer
function! Scratch()
tabnew
noswapfile hide enew
setlocal buftype=nofile
setlocal bufhidden=hide
"setlocal nobuflisted
"lcd ~
file scratch
endfunction
"*****************************************************************************
"" COC
"*****************************************************************************
" 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
" let g:coc_global_extensions = ['coc-solargraph']
"*****************************************************************************
"" Copy/Paste/Cut
"*****************************************************************************
if has('unnamedplus')
set clipboard=unnamed,unnamedplus
endif
noremap YY "+y<CR>
noremap <leader>p "+gP<CR>
noremap XX "+x<CR>
if has('macunix')
" pbcopy for OSX copy/paste
vmap <C-x> :!pbcopy<CR>
vmap <C-c> :w !pbcopy<CR><CR>
endif
"*****************************************************************************
"" deoplete
"*****************************************************************************
""deoplete
let g:deoplete#enable_at_startup = 1
let g:auto_complete_popup = "manual"
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ deoplete#mappings#manual_complete()
function! s:check_back_space() abort "{{{
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction"}}}
"*****************************************************************************
"" neosnippet
"*****************************************************************************
" " Plugin key-mappings.
" " Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <C-k> <Plug>(neosnippet_expand_or_jump)
" smap <C-k> <Plug>(neosnippet_expand_or_jump)
" xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
" if has('conceal')
" set conceallevel=2 concealcursor=niv
" endif
" " To use Honza's Vim Snippets
" let g:neosnippet#snippets_directory='~/.config/nvim/plugged/vim-snippets/snippets'
"*****************************************************************************
"" Encoding
"*****************************************************************************
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
let g:far#enable_undo=1
"*****************************************************************************
"" fish
"*****************************************************************************
if &shell =~# 'fish$'
set shell=sh
endif
"*****************************************************************************
"" fzf
"*****************************************************************************
set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
let $FZF_DEFAULT_COMMAND = "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'dist/**' -prune -o -type f -print -o -type l -print 2> /dev/null"
" nnoremap <silent> <leader>b :Buffers<CR>
nnoremap <silent> <leader>e :FZF -m<CR>
"Recovery commands from history through FZF
nmap <leader>y :History:<CR>
"NOTE: To open a file in a new tab CTRL-V, CTRL-X, or CTRL-T
"*****************************************************************************
"" General Settings
"*****************************************************************************
"Use `onedark` colour scheme
" colorscheme onedark
colo onedark
"Syntax highlighting from start unless 1000 lines (instead of 200)
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=1000
augroup END
"Refresh file when changed on disk
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI *
\ if mode() !~ '\v(c|r.?|!|t)' && getcmdwintype() == '' | checktime | endif
"Autowrite
set autowriteall
" :set tabstop=2
" :set shiftwidth=2
" :set expandtab
" Folding
set fdm=syntax
set nofoldenable
" set foldlevel=0
" Built-in Neovim autocomplete
cnoremap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
"NERDTree can modify files
set modifiable
"Add Cucumber filetype detection
au BufRead,BufNewFile *.cucumber set filetype=cucumber
"Various completion plugins require this
filetype plugin on
"Omni completion
" set omnifunc=syntaxcomplete#Complete
"Spell check
nnoremap <F10> :set spell! spelllang=en_gb,lt,fr,he!<CR>
"Center screen when going into INSERT mode
" autocmd InsertEnter * norm zz
"Thin line cursor in INSERT mode
highlight Cursor guifg=white guibg=black
highlight iCursor guifg=white guibg=steelblue
set guicursor=n-v-c:block-Cursor
set guicursor=i:ver25-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait10
"Highlight current line
autocmd InsertEnter,InsertLeave * set cul!
"Auotmatically split to the right
set splitright
"Vim LateX settings
let g:tex_flavor='latex'
"*****************************************************************************
"" Git
"*****************************************************************************
noremap <Leader>ga :Gwrite<CR>
noremap <Leader>gc :Gcommit<CR>
noremap <Leader>gsh :Gpush<CR>
noremap <Leader>gll :Gpull<CR>
noremap <Leader>gs :Gstatus<CR>
noremap <Leader>gb :Gblame<CR>
noremap <Leader>gd :Gvdiff<CR>
noremap <Leader>gr :Gremove<CR>
"" Open current line on GitHub
nnoremap <Leader>o :.Gbrowse<CR>
set diffopt+=vertical
"*****************************************************************************
"" Go Language
"*****************************************************************************
" autocmd BufWritePost *.go !go test
"*****************************************************************************
"" grep.vim
"*****************************************************************************
" grep.vim
nnoremap <silent> <leader>f :Rgrep<CR>
let Grep_Default_Options = '-IR'
let Grep_Skip_Files = '*.log *.db'
let Grep_Skip_Dirs = '.git node_modules'
"*****************************************************************************
"" HTML
"*****************************************************************************
" for html files, 2 spaces
autocmd Filetype html setlocal ts=2 sw=2 expandtab
"View HTML Text
function! ViewHtmlText(url)
if !empty(a:url)
new
setlocal buftype=nofile bufhidden=hide noswapfile
execute 'r !elinks ' . a:url . ' -dump -dump-width ' . winwidth(0)
1d
endif
endfunction
" Save and view text for current html file.
nnoremap <Leader>H :update<Bar>call ViewHtmlText(expand('%:p'))<CR>
" " View text for visually selected url.
vnoremap <Leader>h y:call ViewHtmlText(@*)<CR>
" View text for URL from clipboard.
" On Linux, use @* for current selection or @+ for text in clipboard.
nnoremap <Leader>h :call ViewHtmlText(@+)<CR>
"*****************************************************************************
"" Emmet
"*****************************************************************************
" let g:user_emmet_install_global = 0
" autocmd FileType html,css,erb EmmetInstall
let g:user_emmet_leader_key=','
"*****************************************************************************
"" Indentations, Tabs, Whitespaces
"*****************************************************************************
"" Fix backspace indent
set backspace=indent,eol,start
"" Tabs. May be overridden by autocmd rules
set tabstop=2
set softtabstop=0
set shiftwidth=2
set expandtab
" remove trailing whitespaces
command! FixWhitespace :%s/\s\+$//e
"Fix indentation for the whole file
" nnoremap <F7> gg=G<C-o><C-o>
"*****************************************************************************
"" JavaScript
"*****************************************************************************
" javascript
let g:javascript_enable_domhtmlcss = 1
" vim-javascript
augroup vimrc-javascript
autocmd!
autocmd FileType javascript setl tabstop=4|setl shiftwidth=4|setl expandtab softtabstop=4
augroup END
"*****************************************************************************
"" LanguageClient-Neovim
"*****************************************************************************
" Tell the language client to use the default IP and port
" that Solargraph runs on
" let g:LanguageClient_serverCommands = {
" \ 'ruby': ['tcp://localhost:7658']
" \ }
" Don't send a stop signal to the server when exiting vim.
" This is optional, but I don't like having to restart Solargraph
" every time I restart vim.
" let g:LanguageClient_autoStop = 0
" Configure ruby omni-completion to use the language client:
" autocmd FileType ruby setlocal omnifunc=LanguageClient#complete
" Required for operations modifying multiple buffers like rename.
" set hidden
" let g:LanguageClient_serverCommands = {
" \ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
" \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
" \ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
" \ 'python': ['/usr/local/bin/pyls'],
" \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'],
" \ }
" nnoremap <F5> :call LanguageClient_contextMenu()<CR>
" " Or map each action separately
" nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
" nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
" nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
"*****************************************************************************
"" Macros
"*****************************************************************************
nnoremap <leader>gcr If<esc>A # rubocop:disable RSpec/Focus<esc>
nnoremap <leader>sal gg<esc>O$seeds_already_loaded = true<esc><C-o>
nnoremap <leader>gms gg<esc>O$minimal_seeds = true<esc><C-o>
"*****************************************************************************
"" Markdown
"*****************************************************************************
"Markdown plugin
" filetype plugin on
let g:vim_markdown_conceal = 0
let g:vim_markdown_conceal_code_blocks = 0
"Uncomment to override defaults:
"let g:instant_markdown_slow = 1
"let g:instant_markdown_autostart = 0
"let g:instant_markdown_open_to_the_world = 1
"let g:instant_markdown_allow_unsafe_content = 1
"let g:instant_markdown_allow_external_content = 0
"let g:instant_markdown_mathjax = 1
"let g:instant_markdown_logfile = '/tmp/instant_markdown.log'
"let g:instant_markdown_autoscroll = 0
"let g:instant_markdown_port = 8888
"let g:instant_markdown_python = 1
"MarkdownPreview
" set to 1, nvim will open the preview window after entering the markdown buffer
" default: 0
let g:mkdp_auto_start = 1
" set to 1, the nvim will auto close current preview window when change
" from markdown buffer to another buffer
" default: 1
let g:mkdp_auto_close = 1
" set to 1, the vim will refresh markdown when save the buffer or
" leave from insert mode, default 0 is auto refresh markdown as you edit or
" move the cursor
" default: 0
let g:mkdp_refresh_slow = 0
" set to 1, the MarkdownPreview command can be use for all files,
" by default it can be use in markdown file
" default: 0
let g:mkdp_command_for_global = 0
" set to 1, preview server available to others in your network
" by default, the server listens on localhost (127.0.0.1)
" default: 0
let g:mkdp_open_to_the_world = 0
" use custom IP to open preview page
" useful when you work in remote vim and preview on local browser
" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9
" default empty
let g:mkdp_open_ip = ''
" specify browser to open preview page
" default: ''
let g:mkdp_browser = ''
" set to 1, echo preview page url in command line when open preview page
" default is 0
let g:mkdp_echo_preview_url = 0
" a custom vim function name to open preview page
" this function will receive url as param
" default is empty
let g:mkdp_browserfunc = ''
" options for markdown render
" mkit: markdown-it options for render
" katex: katex options for math
" uml: markdown-it-plantuml options
" maid: mermaid options
" disable_sync_scroll: if disable sync scroll, default 0
" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle'
" middle: mean the cursor position alway show at the middle of the preview page
" top: mean the vim top viewport alway show at the top of the preview page
" relative: mean the cursor position alway show at the relative positon of the preview page
" hide_yaml_meta: if hide yaml metadata, default is 1
" sequence_diagrams: js-sequence-diagrams options
" content_editable: if enable content editable for preview page, default: v:false
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1,
\ 'sequence_diagrams': {},
\ 'flowchart_diagrams': {},
\ 'content_editable': v:false
\ }
" use a custom markdown style must be absolute path
" like '/Users/username/markdown.css' or expand('~/markdown.css')
let g:mkdp_markdown_css = ''
" use a custom highlight style must absolute path
" like '/Users/username/highlight.css' or expand('~/highlight.css')
let g:mkdp_highlight_css = ''
" use a custom port to start server or random for empty
let g:mkdp_port = ''
" preview page title
" ${name} will be replace with the file name
let g:mkdp_page_title = '「${name}」'
"*****************************************************************************
"" NERDTree
"*****************************************************************************
"" NERDTree configuration
let g:NERDTreeChDirMode=2
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let g:NERDTreeShowBookmarks=1
let g:nerdtree_tabs_focus_on_files=1
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
let g:NERDTreeWinSize = 50
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
nnoremap <silent> <F2> :NERDTreeFind<CR>
nnoremap <silent> <F3> :NERDTreeToggle<CR>
let g:NERDTreeMapOpenInTab = "l"
"Close NERDTree when you open a file
let NERDTreeQuitOnOpen = 1
"Prettify NERDTree
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
" autocmd FileType nerdtree setlocal noreadonly
"*****************************************************************************
"" polyglot
"*****************************************************************************
" Syntax highlight
" Default highlight is better than polyglot
let g:polyglot_disabled = ['python']
let python_highlight_all = 1
"*****************************************************************************
"" Python
"*****************************************************************************
" vim-python
augroup vimrc-python
autocmd!
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 colorcolumn=79
\ formatoptions+=croq softtabstop=4
\ cinwords=if,elif,else,for,while,try,except,finally,def,class,with
augroup END
"*****************************************************************************
"" jedi-vim
"*****************************************************************************
let g:jedi#popup_on_dot = 0
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_definitions_command = "<leader>d"
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#rename_command = "<leader>r"
let g:jedi#show_call_signatures = "0"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#smart_auto_mappings = 0
"*****************************************************************************
"" ripgrep
"*****************************************************************************
if executable('rg')
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
set grepprg=rg\ --vimgrep
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
endif
"*****************************************************************************
"" rspec.vim
"*****************************************************************************
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
"Prepend `bundle exec`
let g:rspec_command = "!bundle exec rspec {spec}"
"*****************************************************************************
"" Ruby
"*****************************************************************************
"Omnicomplete
let g:ruby_host_prog = '~/.rbenv/shims/neovim-ruby-host'
let g:ruby_path = system('echo $HOME/.rbenv/shims')
" ruby
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
augroup vimrc-ruby
autocmd!
autocmd BufNewFile,BufRead *.rb,*.rbw,*.gemspec setlocal filetype=ruby
autocmd FileType ruby set tabstop=2|set shiftwidth=2|set expandtab softtabstop=2
augroup END
" For ruby refactory
if has('nvim')
runtime! macros/matchit.vim
else
packadd! matchit
endif
" Ruby refactory
nnoremap <leader>rap :RAddParameter<cr>
nnoremap <leader>rcpc :RConvertPostConditional<cr>
nnoremap <leader>rel :RExtractLet<cr>
vnoremap <leader>rec :RExtractConstant<cr>
vnoremap <leader>relv :RExtractLocalVariable<cr>
nnoremap <leader>rit :RInlineTemp<cr>
vnoremap <leader>rrlv :RRenameLocalVariable<cr>
vnoremap <leader>rriv :RRenameInstanceVariable<cr>
vnoremap <leader>rem :RExtractMethod<cr>
"Run RSpec in Tmux
" map <Leader>rt :w<cr>:call RunCurrentTest('!ts be rspec')<CR>
" Thoughtbot Vim-RSpec
let g:rspec_command = "Dispatch bundle exec rspec {spec}"
" let g:rspec_command = "!bundle exec rspec {spec}"
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
" map <LocalLeader>s :e db/schema.rb<CR>
"*****************************************************************************
"" Search
"*****************************************************************************
"" Clean search (highlight)
nnoremap <silent> <leader><space> :noh<cr>
"" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
set fileformats=unix,dos,mac
if exists('$SHELL')
set shell=$SHELL
else
set shell=/bin/sh
endif
"Search for visually selected text
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
"*****************************************************************************
"" Session Management
"*****************************************************************************
nnoremap <leader>so :OpenSession<Space>
nnoremap <leader>ss :SaveSession<Space>
nnoremap <leader>sd :DeleteSession<CR>
nnoremap <leader>sc :CloseSession<CR>
let g:session_directory = "~/.config/nvim/session"
let g:session_autoload = "no"
let g:session_autosave = "yes"
let g:session_autosave_periodic = 1
let g:session_command_aliases = 1
let g:session_autosave_silent = 1
"*****************************************************************************
"" The Silver Searcher
"*****************************************************************************
if executable('ag')
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
set grepprg=ag\ --nogroup\ --nocolor
endif
let g:startify_session_dir = '~/.config/nvim/session'
let g:startify_lists = [
\ { 'type': 'files', 'header': [' Files'] },
\ { 'type': 'dir', 'header': [' Current Directory '. getcwd()] },
\ { 'type': 'sessions', 'header': [' Sessions'] },
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
\ ]
let g:startify_bookmarks = [
\ { 'i': '~/.config/nvim/init.vim' },
\ '~/Development/inspiregroup/chameleon/creator/services/creator-backend',
\ '~/Development/publish/clockworkpc.github.io',
\ '~/Development/inspiregroup/chameleon/collect',
\ ]
let g:startify_session_autoload = 1
let g:startify_fortune_use_unicode = 1
let g:startify_session_persistence = 1
let g:startify_enable_special = 0
"*****************************************************************************
"" Tagbar
"*****************************************************************************
nmap <silent> <F4> :TagbarToggle<CR>
let g:tagbar_autofocus = 1
let g:tagbar_type_ruby = {
\ 'kinds' : [
\ 'm:modules',
\ 'c:classes',
\ 'd:describes',
\ 'C:contexts',
\ 'f:methods',
\ 'F:singleton methods'
\ ]
\ }
"*****************************************************************************
"" Terminal Emulation
"*****************************************************************************
" terminal emulation
nnoremap <silent> <leader>sh :terminal<CR>
"Open a terminal in a new tab
map <silent> <M-C-N> :tabnew <bar> :terminal<CR>
"*****************************************************************************
"" textobj-rubyblock
"*****************************************************************************
runtime macros/matchit.vim
set nocompatible
if has("autocmd")
filetype indent plugin on
endif
let g:textobj_ruby_more_mappings = 1
"*****************************************************************************
"" Typescript
"*****************************************************************************
" typescript
let g:yats_host_keyword = 1
"*****************************************************************************
"" UltiSnips
"*****************************************************************************
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
" let g:UltiSnipsExpandTrigger="<tab>"
" let g:UltiSnipsJumpForwardTrigger="<c-b>"
" let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" let g:UltiSnipsEditSplit="vertical"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
let g:UltiSnipsEditSplit="vertical"
" let g:UltiSnipsSnippetDirectories=["UltiSnips", "myUltiSnips"]
"*****************************************************************************
"" vim-airline
"*****************************************************************************
let g:airline_theme = 'powerlineish'
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline#extensions#tagbar#enabled = 1
let g:airline_skip_empty_sections = 1
"python
let g:airline#extensions#virtualenv#enabled = 1
"*****************************************************************************
"" Vimroom
"*****************************************************************************
"Vimroom
let g:goyo_width=100
let g:goyo_margin_top = 2
let g:goyo_margin_bottom = 2
nnoremap <silent> <leader>z :Goyo<cr>
"*****************************************************************************
"" vim-ruby-doc
"*****************************************************************************
" For some reason this plugin doesn't work anymore,
" so I hacked together the same functionality, using its example.
" Replace 'firefox' with whatever command you need instead.
let g:ruby_doc_url_template="http://rubydoc.info/search/stdlib/core?q=%"
let g:rails_doc_url_template="http://api.rubyonrails.org/?q=%"
let g:rspec_doc_url_template='https://www.relishapp.com/rspec/search?query=%'
function! AnyRDoc(url_template)
if &ft =~ "ruby"
else
return
endif
let s:wordUnderCursor = expand("<cword>")
let s:url = substitute(a:url_template, "%", s:wordUnderCursor, "g")
let s:cmd = "!firefox \"" . s:url . "\""
execute s:cmd
endfunction
map RB :call AnyRDoc(ruby_doc_url_template)<CR>
map RR :call AnyRDoc(rails_doc_url_template)<CR>
map RS :call AnyRDoc(rspec_doc_url_template)<CR>
let g:vimwiki_list = [{'path': '~/Development/PanhandleDoorDocuments/', 'path_html': '~/public_html/'}]
"*****************************************************************************
"" visualbell
"*****************************************************************************
" Disable visualbell
set noerrorbells visualbell t_vb=
if has('autocmd')
autocmd GUIEnter * set visualbell t_vb=
endif
"*****************************************************************************
"" Visual Mode
"*****************************************************************************
"" Vmap for maintain Visual Mode after shifting > and <
vmap < <gv
vmap > >gv
"" Move visual block
" vnoremap J :m '>+1<CR>gv=gv
" vnoremap K :m '<-2<CR>gv=gv
"*****************************************************************************
"" Visual Settings
"*****************************************************************************
syntax on
set ruler
set number
let no_buffers_menu=1
set mousemodel=popup
set t_Co=256
set guioptions=egmrti
set gfn=Monospace\ 10
if has("gui_running")
if has("gui_mac") || has("gui_macvim")
set guifont=Menlo:h12
set transparency=7
endif
else
let g:CSApprox_loaded = 1
" IndentLine
let g:indentLine_enabled = 1
let g:indentLine_concealcursor = 0
let g:indentLine_char = '┆'
let g:indentLine_faster = 1
endif
"" Disable the blinking cursor.
set gcr+=a:blinkon0
set scrolloff=3
"" Status bar
set laststatus=2
"" Use modeline overrides
set modeline
set modelines=10
set title
set titleold="Terminal"
set titlestring=%F
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
if exists("*fugitive#statusline")
set statusline+=%{fugitive#statusline()}
endif
"*****************************************************************************
"" XML
"*****************************************************************************
function! DoFormatXML()
:%s/></>\r</g
:0
=:$
endfunction
com! FormatXML call DoFormatXML()
"*****************************************************************************
"" YAML
"*****************************************************************************
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
set foldlevelstart=20
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'
" let g:ale_lint_on_text_changed = 'never'
vnoremap ;rv c<C-O>:set revins<CR><C-R>"<Esc>:set norevins<CR>
"*****************************************************************************
"" CPC NEOVIM CONFIGURATION
"" Maintainer: Alexander JK Garber
"*****************************************************************************
"*****************************************************************************
"" Vim-PLug core
"*****************************************************************************
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
let g:vim_bootstrap_langs = "go,haskell,html,javascript,lisp,python,ruby,typescript"
let g:vim_bootstrap_editor = "nvim" " nvim or 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
" Required:
call plug#begin(expand('~/.config/nvim/plugged'))
"****************************************************************************
"" Project
"****************************************************************************
" Functional Start Screen
" Plug 'mhinz/vim-startify'
" Treeview file browser in VIM
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
" Plug 'MarSoft/nerdtree-grep-plugin'
" Status bar above and below
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Show changed lines in gutter
Plug 'airblade/vim-gitgutter'
" Search for strings in files
Plug 'vim-scripts/grep.vim'
"GVim-only colour schemes
Plug 'vim-scripts/CSApprox'
" Fuzzy file search
if isdirectory('/usr/local/opt/fzf')
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
else
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
endif
let g:make = 'gmake'
if exists('make')
let g:make = 'make'
endif
" Find and Replace
Plug 'brooth/far.vim'
" Interactive command execution
Plug 'Shougo/vimproc.vim', {'do': g:make}
"" Vim-Session
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'
" ctags
" Plug 'ludovicchabant/vim-gutentags'
" Plug 'craigemery/vim-autotag'
"codequery
" Plug 'Shougo/unite.vim'
" Plug 'devjoe/vim-codequery'
"grep replace
Plug 'skwp/greplace.vim'
"view images
Plug 'ashisha/image.vim'
"Reload files changed on disk
Plug 'djoshea/vim-autoread'
" Fountain plugin
Plug 'kblin/vim-fountain'
" Close buffers
Plug 'Asheq/close-buffers.vim'
" Conquer of Code (Autocomplete)
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Autosave sessions
Plug 'tpope/vim-obsession'
"Use Vim in the browser
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
"****************************************************************************
"" Editor (NORMAL MODE ONLY)
"****************************************************************************
" Comment out lines with gcc or gc in visual mode
Plug 'tpope/vim-commentary'
" Tag viewer for class and method definitions
Plug 'majutsushi/tagbar'
" Display thin vertical lines for indentations
Plug 'Yggdroot/indentLine'
" Repeat a plug-in command
Plug 'tpope/vim-repeat'
" Improved clipping of text
Plug 'svermeulen/vim-easyclip'
"Replace double quotes, single quotes, etc
Plug 'tpope/vim-surround'
"Split single line to multiline and visa versa
Plug 'AndrewRadev/splitjoin.vim'
"Word Motion
" Plug 'chaoren/vim-wordmotion'
"Resize Windows
Plug 'simeji/winresizer'
"****************************************************************************
"" Editor (INSERT MODE ONLY)
"****************************************************************************
"Autocomplete
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'ervandew/supertab'
"Snippets
Plug 'sirver/UltiSnips'
Plug 'honza/vim-snippets'
" Autocomplete brackets, quotes, etc.
Plug 'Raimondi/delimitMate'
"Markdown tables
Plug 'dhruvasagar/vim-table-mode'
"
"Pairs of handy bracket mappings
Plug 'tpope/vim-unimpaired'
"Horizontal navigation"
Plug 'unblevable/quick-scope'
"Automatic bullet and numbered lists
Plug 'dkarter/bullets.vim'
"Automatic newline and indentation between brackets
Plug 'jiangmiao/auto-pairs'
"Merge git conflicts
Plug 'christoomey/vim-conflicted'
"****************************************************************************
"" Editor (VISUAL MODE ONLY)
"****************************************************************************
"Select a ruby block in VISUAL mode
Plug 'nelstrom/vim-textobj-rubyblock'
" dependency of vim-textobj-rubyblock
Plug 'kana/vim-textobj-user'
"Scratch buffer
" Plug 'mtth/scratch.vim'
"****************************************************************************
"" Editor (COMBINED MODES)
"****************************************************************************
"Make Goyo even nicer
Plug 'amix/vim-zenroom2'
"Code linting
Plug 'dense-analysis/ale'
Plug 'prettier/vim-prettier'
"OrgMode for VIM
Plug 'jceb/vim-orgmode'
"Atomesque coloures
Plug 'joshdick/onedark.vim'
"Distraction-free editing
Plug 'junegunn/goyo.vim'
"Markdown preview
" Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
" Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
" Plug 'iamcco/markdown-preview.nvim'
Plug 'suan/vim-instant-markdown', {'for': 'markdown', 'do': 'yarn install'}
"Floating Terminal
Plug 'voldikss/vim-floaterm'
"Cucumber syntax highlighting
Plug 'barboza/vim-cucumber-string-highlight'
""****************************************************************************
"" Version Control
"****************************************************************************
" Git wrapper
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb' " required by fugitive to :Gbrowse
" GraphQL syntax highlighting
Plug 'jparise/vim-graphql'
"***************************************************************************
"" Ruby and Rails
"***************************************************************************
"Refactor
Plug 'ecomba/vim-ruby-refactoring'
Plug 'thoughtbot/vim-rspec'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-cucumber'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-rake'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-rbenv'
Plug 'thoughtbot/vim-rspec'
Plug 'vim-ruby/vim-ruby'
"Ruby/Rails/RSpec documentation
" Plug 'lucapette/vim-ruby-doc'
" Toggle Ruby do/end and {}
Plug 'jgdavey/vim-blockle'
"***************************************************************************
"" Other Languages
"***************************************************************************
" go
"" Go Lang Bundle
Plug 'fatih/vim-go', {'do': ':GoInstallBinaries'}
" haskell
"" Haskell Bundle
Plug 'eagletmt/neco-ghc'
Plug 'dag/vim2hs'
Plug 'pbrisbin/vim-syntax-shakespeare'
" html
"" HTML Bundle
Plug 'hail2u/vim-css3-syntax'
" Plug 'gorodinskiy/vim-coloresque'
Plug 'tpope/vim-haml'
Plug 'mattn/emmet-vim'
Plug 'zeekay/vim-beautify'
" javascript
"" Javascript Bundle
Plug 'jelera/vim-javascript-syntax'
" lisp
"" Lisp Bundle
Plug 'vim-scripts/slimv.vim'
" python
"" Python Bundle
Plug 'davidhalter/jedi-vim'
Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'}
" typescript
Plug 'leafgarland/typescript-vim'
Plug 'HerringtonDarkholme/yats.vim'
"VimBeGood (Primeagen)
" Plug 'ThePrimeagen/vim-be-good', {'do': './install.sh'}
"FISH Scripting
Plug 'dag/vim-fish'
"Writing Tools
Plug 'preservim/vim-pencil'
Plug 'dbmrq/vim-ditto'
Plug 'honza/writer.vim'
Plug 'mattn/vim-metarw-gdrive'
" Plug 'vimwiki/vimwiki'
Plug 'vim-latex/vim-latex'
"*****************************************************************************
call plug#end()
"***************************************************************************
"" Core VIM Keybindings
"***************************************************************************"
" Map leader to ,
let mapleader=','
"map LocalLeader to \\
let maplocalleader = "\\"
"Left (h) => [h]
noremap h h
"Up (j) => [t]
noremap t gj
"Down (k) => [n]
noremap n gk
"Right (l) => [s]
noremap s l
"End of line ($) => [-]
noremap - $
"Start of line (^) => [_]
noremap _ ^
"Jump to letter before (t) => [j]
noremap k t
"Sentences
noremap $ s
"m is shadowed by easyclip plugin
noremap gm m
" j/J moves between search mappings
nnoremap j n
nnoremap J N
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
" nnoremap j nzzzv
" nnoremap J Nzzzv
"Move text down
nnoremap <A-t> :m .+1<CR>==
inoremap <A-t> <Esc>:m .+1<CR>==gi
vnoremap <A-t> :m '>+1<CR>gv=gv
"Move text up
nnoremap <A-n> :m .-2<CR>==
inoremap <A-n> <Esc>:m .-2<CR>==gi
vnoremap <A-n> :m '<-2<CR>gv=gv
"*****************************************************************************
"" Mappings
"*****************************************************************************
"" Split
noremap <Leader>h :<C-u>split<CR>
" New buffer rather than the current file
noremap <Leader>v :<C-u>vnew<CR>
" Current file rather than a new buffer
" noremap <Leader>v :<C-u>vsplit<CR>
"*****************************************************************************
"Customised VIM
"*****************************************************************************
"Show how many lines yanked, inter alia
set report=0
"Hybrid line numbers
:set number relativenumber
:augroup numbertoggle
: autocmd!
: autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
: autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
:augroup END
"More natural movement in INSERT mode
behave mswin
"*****************************************************************************
"" Custom Bindings
"*****************************************************************************
"Fix indentation for the whole file
nnoremap <F7> gg=G<C-o><C-o>
" Bind F8 to fixing problems with ALE
nmap <F8> <Plug>(ale_fix)
"Force filetype 'yaml' for yml files
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml foldmethod=manual
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" autocmd BufNewFile,BufRead *.yml set ft=yaml
"Stop line wrap from breaking words
set linebreak
"Skip out of brackets
inoremap <C-e> <C-o>A
"Replace all
nnoremap S :%s///g<Left><Left><Left>
"Jump to next occurrence in INSERT mode
imap <C-j> <Esc>jcaw
"Replace all within a visual selection
" vnoremap S :s/\%V//g<Left><Left><Left>
"Ctrl-A for select all
" vnnoremap <C-a> ggVG
"Replace all matching strings in visual selection
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
" Close all hidden buffers
nnoremap <silent> <C-q> :Bdelete menu<CR>
function! ALEFixFast()
syntax off
exec "ALEFix"
syntax on
endfunction
"Save file, even if no changes
nor <silent> <Leader>w :w<CR>
vnoremap <silent> <C-w> <C-C>:update<CR>
"Close all buffers and quit Neovim
noremap <Leader>' :qall<CR>
"*****************************************************************************
"" Abbreviations
"*****************************************************************************
"" no one is really happy until you have this shortcuts
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall
"*****************************************************************************
"" ALE
"*****************************************************************************
" LINTERS
let g:ale_linters = {
\ 'gql': ['prettier'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\ 'vim': ['vint'],
\}
function! SettingsTurnOff()
"Turns syntax off only in current buffer
exec "syntax clear"
" exec "set nocursorcolumn"
" exec "set nocursorline"
" exec "set norelativenumber"
endfunction
function! SettingsTurnOn()
exec "syntax on"
" exec "set number relativenumber"
exec "AirlineRefresh"
endfunction
augroup YourGroup
autocmd!
autocmd User ALEFixPre call SettingsTurnOff()
autocmd User ALEFixPost call SettingsTurnOn()
augroup END
" FIXERS
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\}
let g:ale_lint_on_enter = 1
let g:ale_completion_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %(code): %%s [%severity%]'
let g:airline#extensions#ale#enabled = 1
" let g:ale_ruby_rubocop_executable = 'rubocop-daemon exec -- --auto-correct'
" set omnifunc=ale#completion#OmniFunc
"*****************************************************************************
"" Autocmd Rules, Functions
"*****************************************************************************
"" Functions
if !exists('*s:setupWrapping')
function s:setupWrapping()
set wrap
set wm=2
set textwidth=80
endfunction
endif
"*****************************************************************************
"" Autocmd Rules
"*****************************************************************************
"" The PC is fast enough, do syntax highlight syncing from start unless 200 lines
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=200
augroup END
"" Remember cursor position
augroup vimrc-remember-cursor-position
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
"" txt
augroup vimrc-wrapping
autocmd!
autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
augroup END
"" make/cmake
augroup vimrc-make-cmake
autocmd!
autocmd FileType make setlocal noexpandtab
autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
augroup END
set autoread
"*****************************************************************************
"" AUTO PAIRS
"*****************************************************************************
" Jump outside '"({
if !exists('g:AutoPairsShortcutJump')
let g:AutoPairsShortcutJump = '<C-l>'
endif
"*****************************************************************************
"" Buffers, Tabs, Windows
"*****************************************************************************
"" Buffer nav
noremap <leader>x :bn<CR>
"" Close buffer
noremap <leader>c :bd<CR>
"" Enable hidden buffers
" set hidden
"" Switching windows
noremap <C-h> <C-w>h
noremap <C-t> <C-w>j
noremap <C-n> <C-w>k
noremap <C-s> <C-w>l
"" Tabs
nnoremap <Tab> gt
nnoremap <S-Tab> gT
nnoremap <silent> <S-t> :tabnew<CR>
"Scratch buffer
function! Scratch()
tabnew
noswapfile hide enew
setlocal buftype=nofile
setlocal bufhidden=hide
"setlocal nobuflisted
"lcd ~
file scratch
endfunction
"*****************************************************************************
"" COC
"*****************************************************************************
" 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
" let g:coc_global_extensions = ['coc-solargraph']
"*****************************************************************************
"" Copy/Paste/Cut
"*****************************************************************************
if has('unnamedplus')
set clipboard=unnamed,unnamedplus
endif
noremap YY "+y<CR>
noremap <leader>p "+gP<CR>
noremap XX "+x<CR>
if has('macunix')
" pbcopy for OSX copy/paste
vmap <C-x> :!pbcopy<CR>
vmap <C-c> :w !pbcopy<CR><CR>
endif
"*****************************************************************************
"" deoplete
"*****************************************************************************
""deoplete
let g:deoplete#enable_at_startup = 1
let g:auto_complete_popup = "manual"
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ deoplete#mappings#manual_complete()
function! s:check_back_space() abort "{{{
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction"}}}
"*****************************************************************************
"" neosnippet
"*****************************************************************************
" " Plugin key-mappings.
" " Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <C-k> <Plug>(neosnippet_expand_or_jump)
" smap <C-k> <Plug>(neosnippet_expand_or_jump)
" xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
" if has('conceal')
" set conceallevel=2 concealcursor=niv
" endif
" " To use Honza's Vim Snippets
" let g:neosnippet#snippets_directory='~/.config/nvim/plugged/vim-snippets/snippets'
"*****************************************************************************
"" Encoding
"*****************************************************************************
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
let g:far#enable_undo=1
"*****************************************************************************
"" fish
"*****************************************************************************
if &shell =~# 'fish$'
set shell=sh
endif
"*****************************************************************************
"" fzf
"*****************************************************************************
set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
let $FZF_DEFAULT_COMMAND = "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'dist/**' -prune -o -type f -print -o -type l -print 2> /dev/null"
" nnoremap <silent> <leader>b :Buffers<CR>
nnoremap <silent> <leader>e :FZF -m<CR>
"Recovery commands from history through FZF
nmap <leader>y :History:<CR>
"NOTE: To open a file in a new tab CTRL-V, CTRL-X, or CTRL-T
"*****************************************************************************
"" General Settings
"*****************************************************************************
"Use `onedark` colour scheme
" colorscheme onedark
colo onedark
"Syntax highlighting from start unless 1000 lines (instead of 200)
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=1000
augroup END
"Refresh file when changed on disk
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI *
\ if mode() !~ '\v(c|r.?|!|t)' && getcmdwintype() == '' | checktime | endif
"Autowrite
set autowriteall
" :set tabstop=2
" :set shiftwidth=2
" :set expandtab
" Folding
set fdm=syntax
set nofoldenable
" set foldlevel=0
" Built-in Neovim autocomplete
cnoremap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
"NERDTree can modify files
set modifiable
"Add Cucumber filetype detection
au BufRead,BufNewFile *.cucumber set filetype=cucumber
"Various completion plugins require this
filetype plugin on
"Omni completion
" set omnifunc=syntaxcomplete#Complete
"Spell check
nnoremap <F10> :set spell! spelllang=en_gb,lt,fr,he!<CR>
"Center screen when going into INSERT mode
" autocmd InsertEnter * norm zz
"Thin line cursor in INSERT mode
highlight Cursor guifg=white guibg=black
highlight iCursor guifg=white guibg=steelblue
set guicursor=n-v-c:block-Cursor
set guicursor=i:ver25-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait10
"Highlight current line
autocmd InsertEnter,InsertLeave * set cul!
"Auotmatically split to the right
set splitright
"Vim LateX settings
let g:tex_flavor='latex'
"*****************************************************************************
"" Git
"*****************************************************************************
noremap <Leader>ga :Gwrite<CR>
noremap <Leader>gc :Gcommit<CR>
noremap <Leader>gsh :Gpush<CR>
noremap <Leader>gll :Gpull<CR>
noremap <Leader>gs :Gstatus<CR>
noremap <Leader>gb :Gblame<CR>
noremap <Leader>gd :Gvdiff<CR>
noremap <Leader>gr :Gremove<CR>
"" Open current line on GitHub
nnoremap <Leader>o :.Gbrowse<CR>
set diffopt+=vertical
"*****************************************************************************
"" Go Language
"*****************************************************************************
" autocmd BufWritePost *.go !go test
"*****************************************************************************
"" grep.vim
"*****************************************************************************
" grep.vim
nnoremap <silent> <leader>f :Rgrep<CR>
let Grep_Default_Options = '-IR'
let Grep_Skip_Files = '*.log *.db'
let Grep_Skip_Dirs = '.git node_modules'
"*****************************************************************************
"" HTML
"*****************************************************************************
" for html files, 2 spaces
autocmd Filetype html setlocal ts=2 sw=2 expandtab
"View HTML Text
function! ViewHtmlText(url)
if !empty(a:url)
new
setlocal buftype=nofile bufhidden=hide noswapfile
execute 'r !elinks ' . a:url . ' -dump -dump-width ' . winwidth(0)
1d
endif
endfunction
" Save and view text for current html file.
nnoremap <Leader>H :update<Bar>call ViewHtmlText(expand('%:p'))<CR>
" " View text for visually selected url.
vnoremap <Leader>h y:call ViewHtmlText(@*)<CR>
" View text for URL from clipboard.
" On Linux, use @* for current selection or @+ for text in clipboard.
nnoremap <Leader>h :call ViewHtmlText(@+)<CR>
"*****************************************************************************
"" Emmet
"*****************************************************************************
" let g:user_emmet_install_global = 0
" autocmd FileType html,css,erb EmmetInstall
let g:user_emmet_leader_key=','
"*****************************************************************************
"" Indentations, Tabs, Whitespaces
"*****************************************************************************
"" Fix backspace indent
set backspace=indent,eol,start
"" Tabs. May be overridden by autocmd rules
set tabstop=2
set softtabstop=0
set shiftwidth=2
set expandtab
" remove trailing whitespaces
command! FixWhitespace :%s/\s\+$//e
"Fix indentation for the whole file
" nnoremap <F7> gg=G<C-o><C-o>
"*****************************************************************************
"" JavaScript
"*****************************************************************************
" javascript
let g:javascript_enable_domhtmlcss = 1
" vim-javascript
augroup vimrc-javascript
autocmd!
autocmd FileType javascript setl tabstop=4|setl shiftwidth=4|setl expandtab softtabstop=4
augroup END
"*****************************************************************************
"" LanguageClient-Neovim
"*****************************************************************************
" Tell the language client to use the default IP and port
" that Solargraph runs on
" let g:LanguageClient_serverCommands = {
" \ 'ruby': ['tcp://localhost:7658']
" \ }
" Don't send a stop signal to the server when exiting vim.
" This is optional, but I don't like having to restart Solargraph
" every time I restart vim.
" let g:LanguageClient_autoStop = 0
" Configure ruby omni-completion to use the language client:
" autocmd FileType ruby setlocal omnifunc=LanguageClient#complete
" Required for operations modifying multiple buffers like rename.
" set hidden
" let g:LanguageClient_serverCommands = {
" \ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
" \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
" \ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
" \ 'python': ['/usr/local/bin/pyls'],
" \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'],
" \ }
" nnoremap <F5> :call LanguageClient_contextMenu()<CR>
" " Or map each action separately
" nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
" nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
" nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
"*****************************************************************************
"" Macros
"*****************************************************************************
nnoremap <leader>gcr If<esc>A # rubocop:disable RSpec/Focus<esc>
nnoremap <leader>sal gg<esc>O$seeds_already_loaded = true<esc><C-o>
nnoremap <leader>gms gg<esc>O$minimal_seeds = true<esc><C-o>
"*****************************************************************************
"" Markdown
"*****************************************************************************
"Markdown plugin
" filetype plugin on
let g:vim_markdown_conceal = 0
let g:vim_markdown_conceal_code_blocks = 0
"Uncomment to override defaults:
"let g:instant_markdown_slow = 1
"let g:instant_markdown_autostart = 0
"let g:instant_markdown_open_to_the_world = 1
"let g:instant_markdown_allow_unsafe_content = 1
"let g:instant_markdown_allow_external_content = 0
"let g:instant_markdown_mathjax = 1
"let g:instant_markdown_logfile = '/tmp/instant_markdown.log'
"let g:instant_markdown_autoscroll = 0
"let g:instant_markdown_port = 8888
"let g:instant_markdown_python = 1
"MarkdownPreview
" set to 1, nvim will open the preview window after entering the markdown buffer
" default: 0
let g:mkdp_auto_start = 1
" set to 1, the nvim will auto close current preview window when change
" from markdown buffer to another buffer
" default: 1
let g:mkdp_auto_close = 1
" set to 1, the vim will refresh markdown when save the buffer or
" leave from insert mode, default 0 is auto refresh markdown as you edit or
" move the cursor
" default: 0
let g:mkdp_refresh_slow = 0
" set to 1, the MarkdownPreview command can be use for all files,
" by default it can be use in markdown file
" default: 0
let g:mkdp_command_for_global = 0
" set to 1, preview server available to others in your network
" by default, the server listens on localhost (127.0.0.1)
" default: 0
let g:mkdp_open_to_the_world = 0
" use custom IP to open preview page
" useful when you work in remote vim and preview on local browser
" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9
" default empty
let g:mkdp_open_ip = ''
" specify browser to open preview page
" default: ''
let g:mkdp_browser = ''
" set to 1, echo preview page url in command line when open preview page
" default is 0
let g:mkdp_echo_preview_url = 0
" a custom vim function name to open preview page
" this function will receive url as param
" default is empty
let g:mkdp_browserfunc = ''
" options for markdown render
" mkit: markdown-it options for render
" katex: katex options for math
" uml: markdown-it-plantuml options
" maid: mermaid options
" disable_sync_scroll: if disable sync scroll, default 0
" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle'
" middle: mean the cursor position alway show at the middle of the preview page
" top: mean the vim top viewport alway show at the top of the preview page
" relative: mean the cursor position alway show at the relative positon of the preview page
" hide_yaml_meta: if hide yaml metadata, default is 1
" sequence_diagrams: js-sequence-diagrams options
" content_editable: if enable content editable for preview page, default: v:false
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1,
\ 'sequence_diagrams': {},
\ 'flowchart_diagrams': {},
\ 'content_editable': v:false
\ }
" use a custom markdown style must be absolute path
" like '/Users/username/markdown.css' or expand('~/markdown.css')
let g:mkdp_markdown_css = ''
" use a custom highlight style must absolute path
" like '/Users/username/highlight.css' or expand('~/highlight.css')
let g:mkdp_highlight_css = ''
" use a custom port to start server or random for empty
let g:mkdp_port = ''
" preview page title
" ${name} will be replace with the file name
let g:mkdp_page_title = '「${name}」'
"*****************************************************************************
"" NERDTree
"*****************************************************************************
"" NERDTree configuration
let g:NERDTreeChDirMode=2
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let g:NERDTreeShowBookmarks=1
let g:nerdtree_tabs_focus_on_files=1
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
let g:NERDTreeWinSize = 50
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
nnoremap <silent> <F2> :NERDTreeFind<CR>
nnoremap <silent> <F3> :NERDTreeToggle<CR>
let g:NERDTreeMapOpenInTab = "l"
"Close NERDTree when you open a file
let NERDTreeQuitOnOpen = 1
"Prettify NERDTree
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
" autocmd FileType nerdtree setlocal noreadonly
"*****************************************************************************
"" polyglot
"*****************************************************************************
" Syntax highlight
" Default highlight is better than polyglot
let g:polyglot_disabled = ['python']
let python_highlight_all = 1
"*****************************************************************************
"" Python
"*****************************************************************************
" vim-python
augroup vimrc-python
autocmd!
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 colorcolumn=79
\ formatoptions+=croq softtabstop=4
\ cinwords=if,elif,else,for,while,try,except,finally,def,class,with
augroup END
"*****************************************************************************
"" jedi-vim
"*****************************************************************************
let g:jedi#popup_on_dot = 0
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_definitions_command = "<leader>d"
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#rename_command = "<leader>r"
let g:jedi#show_call_signatures = "0"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#smart_auto_mappings = 0
"*****************************************************************************
"" ripgrep
"*****************************************************************************
if executable('rg')
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
set grepprg=rg\ --vimgrep
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
endif
"*****************************************************************************
"" rspec.vim
"*****************************************************************************
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
"Prepend `bundle exec`
let g:rspec_command = "!bundle exec rspec {spec}"
"*****************************************************************************
"" Ruby
"*****************************************************************************
"Omnicomplete
let g:ruby_host_prog = '~/.rbenv/shims/neovim-ruby-host'
let g:ruby_path = system('echo $HOME/.rbenv/shims')
" ruby
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
augroup vimrc-ruby
autocmd!
autocmd BufNewFile,BufRead *.rb,*.rbw,*.gemspec setlocal filetype=ruby
autocmd FileType ruby set tabstop=2|set shiftwidth=2|set expandtab softtabstop=2
augroup END
" For ruby refactory
if has('nvim')
runtime! macros/matchit.vim
else
packadd! matchit
endif
" Ruby refactory
nnoremap <leader>rap :RAddParameter<cr>
nnoremap <leader>rcpc :RConvertPostConditional<cr>
nnoremap <leader>rel :RExtractLet<cr>
vnoremap <leader>rec :RExtractConstant<cr>
vnoremap <leader>relv :RExtractLocalVariable<cr>
nnoremap <leader>rit :RInlineTemp<cr>
vnoremap <leader>rrlv :RRenameLocalVariable<cr>
vnoremap <leader>rriv :RRenameInstanceVariable<cr>
vnoremap <leader>rem :RExtractMethod<cr>
"Run RSpec in Tmux
" map <Leader>rt :w<cr>:call RunCurrentTest('!ts be rspec')<CR>
" Thoughtbot Vim-RSpec
let g:rspec_command = "Dispatch bundle exec rspec {spec}"
" let g:rspec_command = "!bundle exec rspec {spec}"
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
" map <LocalLeader>s :e db/schema.rb<CR>
"*****************************************************************************
"" Search
"*****************************************************************************
"" Clean search (highlight)
nnoremap <silent> <leader><space> :noh<cr>
"" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
set fileformats=unix,dos,mac
if exists('$SHELL')
set shell=$SHELL
else
set shell=/bin/sh
endif
"Search for visually selected text
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
"*****************************************************************************
"" Session Management
"*****************************************************************************
nnoremap <leader>so :OpenSession<Space>
nnoremap <leader>ss :SaveSession<Space>
nnoremap <leader>sd :DeleteSession<CR>
nnoremap <leader>sc :CloseSession<CR>
let g:session_directory = "~/.config/nvim/session"
let g:session_autoload = "no"
let g:session_autosave = "yes"
let g:session_autosave_periodic = 1
let g:session_command_aliases = 1
let g:session_autosave_silent = 1
"*****************************************************************************
"" The Silver Searcher
"*****************************************************************************
if executable('ag')
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
set grepprg=ag\ --nogroup\ --nocolor
endif
let g:startify_session_dir = '~/.config/nvim/session'
let g:startify_lists = [
\ { 'type': 'files', 'header': [' Files'] },
\ { 'type': 'dir', 'header': [' Current Directory '. getcwd()] },
\ { 'type': 'sessions', 'header': [' Sessions'] },
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
\ ]
let g:startify_bookmarks = [
\ { 'i': '~/.config/nvim/init.vim' },
\ '~/Development/inspiregroup/chameleon/creator/services/creator-backend',
\ '~/Development/publish/clockworkpc.github.io',
\ '~/Development/inspiregroup/chameleon/collect',
\ ]
let g:startify_session_autoload = 1
let g:startify_fortune_use_unicode = 1
let g:startify_session_persistence = 1
let g:startify_enable_special = 0
"*****************************************************************************
"" Tagbar
"*****************************************************************************
nmap <silent> <F4> :TagbarToggle<CR>
let g:tagbar_autofocus = 1
let g:tagbar_type_ruby = {
\ 'kinds' : [
\ 'm:modules',
\ 'c:classes',
\ 'd:describes',
\ 'C:contexts',
\ 'f:methods',
\ 'F:singleton methods'
\ ]
\ }
"*****************************************************************************
"" Terminal Emulation
"*****************************************************************************
" terminal emulation
nnoremap <silent> <leader>sh :terminal<CR>
"Open a terminal in a new tab
map <silent> <M-C-N> :tabnew <bar> :terminal<CR>
"*****************************************************************************
"" textobj-rubyblock
"*****************************************************************************
runtime macros/matchit.vim
set nocompatible
if has("autocmd")
filetype indent plugin on
endif
let g:textobj_ruby_more_mappings = 1
"*****************************************************************************
"" Typescript
"*****************************************************************************
" typescript
let g:yats_host_keyword = 1
"*****************************************************************************
"" UltiSnips
"*****************************************************************************
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
" let g:UltiSnipsExpandTrigger="<tab>"
" let g:UltiSnipsJumpForwardTrigger="<c-b>"
" let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" let g:UltiSnipsEditSplit="vertical"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
let g:UltiSnipsEditSplit="vertical"
" let g:UltiSnipsSnippetDirectories=["UltiSnips", "myUltiSnips"]
"*****************************************************************************
"" vim-airline
"*****************************************************************************
let g:airline_theme = 'powerlineish'
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline#extensions#tagbar#enabled = 1
let g:airline_skip_empty_sections = 1
"python
let g:airline#extensions#virtualenv#enabled = 1
"*****************************************************************************
"" Vimroom
"*****************************************************************************
"Vimroom
let g:goyo_width=100
let g:goyo_margin_top = 2
let g:goyo_margin_bottom = 2
nnoremap <silent> <leader>z :Goyo<cr>
"*****************************************************************************
"" vim-ruby-doc
"*****************************************************************************
" For some reason this plugin doesn't work anymore,
" so I hacked together the same functionality, using its example.
" Replace 'firefox' with whatever command you need instead.
let g:ruby_doc_url_template="http://rubydoc.info/search/stdlib/core?q=%"
let g:rails_doc_url_template="http://api.rubyonrails.org/?q=%"
let g:rspec_doc_url_template='https://www.relishapp.com/rspec/search?query=%'
function! AnyRDoc(url_template)
if &ft =~ "ruby"
else
return
endif
let s:wordUnderCursor = expand("<cword>")
let s:url = substitute(a:url_template, "%", s:wordUnderCursor, "g")
let s:cmd = "!firefox \"" . s:url . "\""
execute s:cmd
endfunction
map RB :call AnyRDoc(ruby_doc_url_template)<CR>
map RR :call AnyRDoc(rails_doc_url_template)<CR>
map RS :call AnyRDoc(rspec_doc_url_template)<CR>
let g:vimwiki_list = [{'path': '~/Development/PanhandleDoorDocuments/', 'path_html': '~/public_html/'}]
"*****************************************************************************
"" visualbell
"*****************************************************************************
" Disable visualbell
set noerrorbells visualbell t_vb=
if has('autocmd')
autocmd GUIEnter * set visualbell t_vb=
endif
"*****************************************************************************
"" Visual Mode
"*****************************************************************************
"" Vmap for maintain Visual Mode after shifting > and <
vmap < <gv
vmap > >gv
"" Move visual block
" vnoremap J :m '>+1<CR>gv=gv
" vnoremap K :m '<-2<CR>gv=gv
"*****************************************************************************
"" Visual Settings
"*****************************************************************************
syntax on
set ruler
set number
let no_buffers_menu=1
set mousemodel=popup
set t_Co=256
set guioptions=egmrti
set gfn=Monospace\ 10
if has("gui_running")
if has("gui_mac") || has("gui_macvim")
set guifont=Menlo:h12
set transparency=7
endif
else
let g:CSApprox_loaded = 1
" IndentLine
let g:indentLine_enabled = 1
let g:indentLine_concealcursor = 0
let g:indentLine_char = '┆'
let g:indentLine_faster = 1
endif
"" Disable the blinking cursor.
set gcr+=a:blinkon0
set scrolloff=3
"" Status bar
set laststatus=2
"" Use modeline overrides
set modeline
set modelines=10
set title
set titleold="Terminal"
set titlestring=%F
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
if exists("*fugitive#statusline")
set statusline+=%{fugitive#statusline()}
endif
"*****************************************************************************
"" XML
"*****************************************************************************
function! DoFormatXML()
:%s/></>\r</g
:0
=:$
endfunction
com! FormatXML call DoFormatXML()
"*****************************************************************************
"" YAML
"*****************************************************************************
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
set foldlevelstart=20
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'
" let g:ale_lint_on_text_changed = 'never'
"*****************************************************************************
"" CPC NEOVIM CONFIGURATION
"" Maintainer: Alexander JK Garber
"*****************************************************************************
"*****************************************************************************
"" Vim-PLug core
"*****************************************************************************
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
let g:vim_bootstrap_langs = "go,haskell,html,javascript,lisp,python,ruby,typescript"
let g:vim_bootstrap_editor = "nvim" " nvim or 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
" Required:
call plug#begin(expand('~/.config/nvim/plugged'))
"****************************************************************************
"" Project
"****************************************************************************
" Functional Start Screen
" Plug 'mhinz/vim-startify'
" Treeview file browser in VIM
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
" Plug 'MarSoft/nerdtree-grep-plugin'
" Status bar above and below
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Show changed lines in gutter
Plug 'airblade/vim-gitgutter'
" Search for strings in files
Plug 'vim-scripts/grep.vim'
"GVim-only colour schemes
Plug 'vim-scripts/CSApprox'
" Fuzzy file search
if isdirectory('/usr/local/opt/fzf')
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
else
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
endif
let g:make = 'gmake'
if exists('make')
let g:make = 'make'
endif
" Find and Replace
Plug 'brooth/far.vim'
" Interactive command execution
Plug 'Shougo/vimproc.vim', {'do': g:make}
"" Vim-Session
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'
" ctags
" Plug 'ludovicchabant/vim-gutentags'
" Plug 'craigemery/vim-autotag'
"codequery
" Plug 'Shougo/unite.vim'
" Plug 'devjoe/vim-codequery'
"grep replace
Plug 'skwp/greplace.vim'
"view images
Plug 'ashisha/image.vim'
"Reload files changed on disk
Plug 'djoshea/vim-autoread'
" Fountain plugin
Plug 'kblin/vim-fountain'
" Close buffers
Plug 'Asheq/close-buffers.vim'
" Conquer of Code (Autocomplete)
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Autosave sessions
Plug 'tpope/vim-obsession'
"Use Vim in the browser
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
"****************************************************************************
"" Editor (NORMAL MODE ONLY)
"****************************************************************************
" Comment out lines with gcc or gc in visual mode
Plug 'tpope/vim-commentary'
" Tag viewer for class and method definitions
Plug 'majutsushi/tagbar'
" Display thin vertical lines for indentations
Plug 'Yggdroot/indentLine'
" Repeat a plug-in command
Plug 'tpope/vim-repeat'
" Improved clipping of text
Plug 'svermeulen/vim-easyclip'
"Replace double quotes, single quotes, etc
Plug 'tpope/vim-surround'
"Split single line to multiline and visa versa
Plug 'AndrewRadev/splitjoin.vim'
"Word Motion
" Plug 'chaoren/vim-wordmotion'
"Resize Windows
Plug 'simeji/winresizer'
"****************************************************************************
"" Editor (INSERT MODE ONLY)
"****************************************************************************
"Autocomplete
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'ervandew/supertab'
"Snippets
Plug 'sirver/UltiSnips'
Plug 'honza/vim-snippets'
" Autocomplete brackets, quotes, etc.
Plug 'Raimondi/delimitMate'
"Markdown tables
Plug 'dhruvasagar/vim-table-mode'
"
"Pairs of handy bracket mappings
Plug 'tpope/vim-unimpaired'
"Horizontal navigation"
Plug 'unblevable/quick-scope'
"Automatic bullet and numbered lists
Plug 'dkarter/bullets.vim'
"Automatic newline and indentation between brackets
Plug 'jiangmiao/auto-pairs'
"Merge git conflicts
Plug 'christoomey/vim-conflicted'
"****************************************************************************
"" Editor (VISUAL MODE ONLY)
"****************************************************************************
"Select a ruby block in VISUAL mode
Plug 'nelstrom/vim-textobj-rubyblock'
" dependency of vim-textobj-rubyblock
Plug 'kana/vim-textobj-user'
"Scratch buffer
" Plug 'mtth/scratch.vim'
"****************************************************************************
"" Editor (COMBINED MODES)
"****************************************************************************
"Make Goyo even nicer
Plug 'amix/vim-zenroom2'
"Code linting
Plug 'dense-analysis/ale'
Plug 'prettier/vim-prettier'
"OrgMode for VIM
Plug 'jceb/vim-orgmode'
"Atomesque coloures
Plug 'joshdick/onedark.vim'
"Distraction-free editing
Plug 'junegunn/goyo.vim'
"Markdown preview
" Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
" Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
" Plug 'iamcco/markdown-preview.nvim'
Plug 'suan/vim-instant-markdown', {'for': 'markdown', 'do': 'yarn install'}
"Floating Terminal
Plug 'voldikss/vim-floaterm'
"Cucumber syntax highlighting
Plug 'barboza/vim-cucumber-string-highlight'
""****************************************************************************
"" Version Control
"****************************************************************************
" Git wrapper
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb' " required by fugitive to :Gbrowse
" GraphQL syntax highlighting
Plug 'jparise/vim-graphql'
"***************************************************************************
"" Ruby and Rails
"***************************************************************************
"Refactor
Plug 'ecomba/vim-ruby-refactoring'
Plug 'thoughtbot/vim-rspec'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-cucumber'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-rake'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-rbenv'
Plug 'thoughtbot/vim-rspec'
Plug 'vim-ruby/vim-ruby'
"Ruby/Rails/RSpec documentation
" Plug 'lucapette/vim-ruby-doc'
" Toggle Ruby do/end and {}
Plug 'jgdavey/vim-blockle'
"***************************************************************************
"" Other Languages
"***************************************************************************
" go
"" Go Lang Bundle
Plug 'fatih/vim-go', {'do': ':GoInstallBinaries'}
" haskell
"" Haskell Bundle
Plug 'eagletmt/neco-ghc'
Plug 'dag/vim2hs'
Plug 'pbrisbin/vim-syntax-shakespeare'
" html
"" HTML Bundle
Plug 'hail2u/vim-css3-syntax'
" Plug 'gorodinskiy/vim-coloresque'
Plug 'tpope/vim-haml'
Plug 'mattn/emmet-vim'
Plug 'zeekay/vim-beautify'
" javascript
"" Javascript Bundle
Plug 'jelera/vim-javascript-syntax'
" lisp
"" Lisp Bundle
Plug 'vim-scripts/slimv.vim'
" python
"" Python Bundle
Plug 'davidhalter/jedi-vim'
Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'}
" typescript
Plug 'leafgarland/typescript-vim'
Plug 'HerringtonDarkholme/yats.vim'
"VimBeGood (Primeagen)
" Plug 'ThePrimeagen/vim-be-good', {'do': './install.sh'}
"FISH Scripting
Plug 'dag/vim-fish'
"Writing Tools
Plug 'preservim/vim-pencil'
Plug 'dbmrq/vim-ditto'
Plug 'honza/writer.vim'
Plug 'mattn/vim-metarw-gdrive'
" Plug 'vimwiki/vimwiki'
Plug 'vim-latex/vim-latex'
"*****************************************************************************
call plug#end()
"***************************************************************************
"" Core VIM Keybindings
"***************************************************************************"
" Map leader to ,
let mapleader=','
"map LocalLeader to \\
let maplocalleader = "\\"
"Left (h) => [h]
noremap h h
"Up (j) => [t]
noremap t gj
"Down (k) => [n]
noremap n gk
"Right (l) => [s]
noremap s l
"End of line ($) => [-]
noremap - $
"Start of line (^) => [_]
noremap _ ^
"Jump to letter before (t) => [j]
noremap k t
"Sentences
noremap $ s
"m is shadowed by easyclip plugin
noremap gm m
" j/J moves between search mappings
nnoremap j n
nnoremap J N
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
" nnoremap j nzzzv
" nnoremap J Nzzzv
"Move text down
nnoremap <A-t> :m .+1<CR>==
inoremap <A-t> <Esc>:m .+1<CR>==gi
vnoremap <A-t> :m '>+1<CR>gv=gv
"Move text up
nnoremap <A-n> :m .-2<CR>==
inoremap <A-n> <Esc>:m .-2<CR>==gi
vnoremap <A-n> :m '<-2<CR>gv=gv
"*****************************************************************************
"" Mappings
"*****************************************************************************
"" Split
noremap <Leader>h :<C-u>split<CR>
" New buffer rather than the current file
noremap <Leader>v :<C-u>vnew<CR>
" Current file rather than a new buffer
" noremap <Leader>v :<C-u>vsplit<CR>
"*****************************************************************************
"Customised VIM
"*****************************************************************************
"Show how many lines yanked, inter alia
set report=0
"Hybrid line numbers
:set number relativenumber
:augroup numbertoggle
: autocmd!
: autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
: autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
:augroup END
"More natural movement in INSERT mode
behave mswin
"*****************************************************************************
"" Custom Bindings
"*****************************************************************************
"Fix indentation for the whole file
nnoremap <F7> gg=G<C-o><C-o>
" Bind F8 to fixing problems with ALE
nmap <F8> <Plug>(ale_fix)
"Force filetype 'yaml' for yml files
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml foldmethod=manual
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" autocmd BufNewFile,BufRead *.yml set ft=yaml
"Stop line wrap from breaking words
set linebreak
"Skip out of brackets
inoremap <C-e> <C-o>A
"Replace all
nnoremap S :%s///g<Left><Left><Left>
"Jump to next occurrence in INSERT mode
imap <C-j> <Esc>jcaw
"Replace all within a visual selection
" vnoremap S :s/\%V//g<Left><Left><Left>
"Ctrl-A for select all
" vnnoremap <C-a> ggVG
"Replace all matching strings in visual selection
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
" Close all hidden buffers
nnoremap <silent> <C-q> :Bdelete menu<CR>
function! ALEFixFast()
syntax off
exec "ALEFix"
syntax on
endfunction
"Save file, even if no changes
nor <silent> <Leader>w :w<CR>
vnoremap <silent> <C-w> <C-C>:update<CR>
"Close all buffers and quit Neovim
noremap <Leader>' :qall<CR>
"*****************************************************************************
"" Abbreviations
"*****************************************************************************
"" no one is really happy until you have this shortcuts
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall
"*****************************************************************************
"" ALE
"*****************************************************************************
" LINTERS
let g:ale_linters = {
\ 'gql': ['prettier'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\ 'vim': ['vint'],
\}
function! SettingsTurnOff()
"Turns syntax off only in current buffer
exec "syntax clear"
" exec "set nocursorcolumn"
" exec "set nocursorline"
" exec "set norelativenumber"
endfunction
function! SettingsTurnOn()
exec "syntax on"
" exec "set number relativenumber"
exec "AirlineRefresh"
endfunction
augroup YourGroup
autocmd!
autocmd User ALEFixPre call SettingsTurnOff()
autocmd User ALEFixPost call SettingsTurnOn()
augroup END
" FIXERS
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\}
let g:ale_lint_on_enter = 1
let g:ale_completion_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %(code): %%s [%severity%]'
let g:airline#extensions#ale#enabled = 1
" let g:ale_ruby_rubocop_executable = 'rubocop-daemon exec -- --auto-correct'
" set omnifunc=ale#completion#OmniFunc
"*****************************************************************************
"" Autocmd Rules, Functions
"*****************************************************************************
"" Functions
if !exists('*s:setupWrapping')
function s:setupWrapping()
set wrap
set wm=2
set textwidth=80
endfunction
endif
"*****************************************************************************
"" Autocmd Rules
"*****************************************************************************
"" The PC is fast enough, do syntax highlight syncing from start unless 200 lines
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=200
augroup END
"" Remember cursor position
augroup vimrc-remember-cursor-position
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
"" txt
augroup vimrc-wrapping
autocmd!
autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
augroup END
"" make/cmake
augroup vimrc-make-cmake
autocmd!
autocmd FileType make setlocal noexpandtab
autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
augroup END
set autoread
"*****************************************************************************
"" AUTO PAIRS
"*****************************************************************************
" Jump outside '"({
if !exists('g:AutoPairsShortcutJump')
let g:AutoPairsShortcutJump = '<C-l>'
endif
"*****************************************************************************
"" Buffers, Tabs, Windows
"*****************************************************************************
"" Buffer nav
noremap <leader>x :bn<CR>
"" Close buffer
noremap <leader>c :bd<CR>
"" Enable hidden buffers
" set hidden
"" Switching windows
noremap <C-h> <C-w>h
noremap <C-t> <C-w>j
noremap <C-n> <C-w>k
noremap <C-s> <C-w>l
"" Tabs
nnoremap <Tab> gt
nnoremap <S-Tab> gT
nnoremap <silent> <S-t> :tabnew<CR>
"Scratch buffer
function! Scratch()
tabnew
noswapfile hide enew
setlocal buftype=nofile
setlocal bufhidden=hide
"setlocal nobuflisted
"lcd ~
file scratch
endfunction
"*****************************************************************************
"" COC
"*****************************************************************************
" 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
" let g:coc_global_extensions = ['coc-solargraph']
"*****************************************************************************
"" Copy/Paste/Cut
"*****************************************************************************
if has('unnamedplus')
set clipboard=unnamed,unnamedplus
endif
noremap YY "+y<CR>
noremap <leader>p "+gP<CR>
noremap XX "+x<CR>
if has('macunix')
" pbcopy for OSX copy/paste
vmap <C-x> :!pbcopy<CR>
vmap <C-c> :w !pbcopy<CR><CR>
endif
"*****************************************************************************
"" deoplete
"*****************************************************************************
""deoplete
let g:deoplete#enable_at_startup = 1
let g:auto_complete_popup = "manual"
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ deoplete#mappings#manual_complete()
function! s:check_back_space() abort "{{{
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction"}}}
"*****************************************************************************
"" neosnippet
"*****************************************************************************
" " Plugin key-mappings.
" " Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <C-k> <Plug>(neosnippet_expand_or_jump)
" smap <C-k> <Plug>(neosnippet_expand_or_jump)
" xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
" if has('conceal')
" set conceallevel=2 concealcursor=niv
" endif
" " To use Honza's Vim Snippets
" let g:neosnippet#snippets_directory='~/.config/nvim/plugged/vim-snippets/snippets'
"*****************************************************************************
"" Encoding
"*****************************************************************************
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
let g:far#enable_undo=1
"*****************************************************************************
"" fish
"*****************************************************************************
if &shell =~# 'fish$'
set shell=sh
endif
"*****************************************************************************
"" fzf
"*****************************************************************************
set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
let $FZF_DEFAULT_COMMAND = "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'dist/**' -prune -o -type f -print -o -type l -print 2> /dev/null"
" nnoremap <silent> <leader>b :Buffers<CR>
nnoremap <silent> <leader>e :FZF -m<CR>
"Recovery commands from history through FZF
nmap <leader>y :History:<CR>
"NOTE: To open a file in a new tab CTRL-V, CTRL-X, or CTRL-T
"*****************************************************************************
"" General Settings
"*****************************************************************************
"Use `onedark` colour scheme
" colorscheme onedark
colo onedark
"Syntax highlighting from start unless 1000 lines (instead of 200)
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=1000
augroup END
"Refresh file when changed on disk
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI *
\ if mode() !~ '\v(c|r.?|!|t)' && getcmdwintype() == '' | checktime | endif
"Autowrite
set autowriteall
" :set tabstop=2
" :set shiftwidth=2
" :set expandtab
" Folding
set fdm=syntax
set nofoldenable
" set foldlevel=0
" Built-in Neovim autocomplete
cnoremap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
"NERDTree can modify files
set modifiable
"Add Cucumber filetype detection
au BufRead,BufNewFile *.cucumber set filetype=cucumber
"Various completion plugins require this
filetype plugin on
"Omni completion
" set omnifunc=syntaxcomplete#Complete
"Spell check
nnoremap <F10> :set spell! spelllang=en_gb,lt,fr,he!<CR>
"Center screen when going into INSERT mode
" autocmd InsertEnter * norm zz
"Thin line cursor in INSERT mode
highlight Cursor guifg=white guibg=black
highlight iCursor guifg=white guibg=steelblue
set guicursor=n-v-c:block-Cursor
set guicursor=i:ver25-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait10
"Highlight current line
autocmd InsertEnter,InsertLeave * set cul!
"Auotmatically split to the right
set splitright
"Vim LateX settings
let g:tex_flavor='latex'
let g:python3_host_prog = '/usr/bin/python3'
let g:python_host_prog = '/usr/bin/python2'
"*****************************************************************************
"" Git
"*****************************************************************************
noremap <Leader>ga :Gwrite<CR>
noremap <Leader>gc :Gcommit<CR>
noremap <Leader>gsh :Gpush<CR>
noremap <Leader>gll :Gpull<CR>
noremap <Leader>gs :Gstatus<CR>
noremap <Leader>gb :Gblame<CR>
noremap <Leader>gd :Gvdiff<CR>
noremap <Leader>gr :Gremove<CR>
"" Open current line on GitHub
nnoremap <Leader>o :.Gbrowse<CR>
set diffopt+=vertical
"*****************************************************************************
"" Go Language
"*****************************************************************************
" autocmd BufWritePost *.go !go test
"*****************************************************************************
"" grep.vim
"*****************************************************************************
" grep.vim
nnoremap <silent> <leader>f :Rgrep<CR>
let Grep_Default_Options = '-IR'
let Grep_Skip_Files = '*.log *.db'
let Grep_Skip_Dirs = '.git node_modules'
"*****************************************************************************
"" HTML
"*****************************************************************************
" for html files, 2 spaces
autocmd Filetype html setlocal ts=2 sw=2 expandtab
"View HTML Text
function! ViewHtmlText(url)
if !empty(a:url)
new
setlocal buftype=nofile bufhidden=hide noswapfile
execute 'r !elinks ' . a:url . ' -dump -dump-width ' . winwidth(0)
1d
endif
endfunction
" Save and view text for current html file.
nnoremap <Leader>H :update<Bar>call ViewHtmlText(expand('%:p'))<CR>
" " View text for visually selected url.
vnoremap <Leader>h y:call ViewHtmlText(@*)<CR>
" View text for URL from clipboard.
" On Linux, use @* for current selection or @+ for text in clipboard.
nnoremap <Leader>h :call ViewHtmlText(@+)<CR>
"*****************************************************************************
"" Emmet
"*****************************************************************************
" let g:user_emmet_install_global = 0
" autocmd FileType html,css,erb EmmetInstall
let g:user_emmet_leader_key=','
"*****************************************************************************
"" Indentations, Tabs, Whitespaces
"*****************************************************************************
"" Fix backspace indent
set backspace=indent,eol,start
"" Tabs. May be overridden by autocmd rules
set tabstop=2
set softtabstop=0
set shiftwidth=2
set expandtab
" remove trailing whitespaces
command! FixWhitespace :%s/\s\+$//e
"Fix indentation for the whole file
" nnoremap <F7> gg=G<C-o><C-o>
"*****************************************************************************
"" JavaScript
"*****************************************************************************
" javascript
let g:javascript_enable_domhtmlcss = 1
" vim-javascript
augroup vimrc-javascript
autocmd!
autocmd FileType javascript setl tabstop=4|setl shiftwidth=4|setl expandtab softtabstop=4
augroup END
"*****************************************************************************
"" LanguageClient-Neovim
"*****************************************************************************
" Tell the language client to use the default IP and port
" that Solargraph runs on
" let g:LanguageClient_serverCommands = {
" \ 'ruby': ['tcp://localhost:7658']
" \ }
" Don't send a stop signal to the server when exiting vim.
" This is optional, but I don't like having to restart Solargraph
" every time I restart vim.
" let g:LanguageClient_autoStop = 0
" Configure ruby omni-completion to use the language client:
" autocmd FileType ruby setlocal omnifunc=LanguageClient#complete
" Required for operations modifying multiple buffers like rename.
" set hidden
" let g:LanguageClient_serverCommands = {
" \ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
" \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
" \ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
" \ 'python': ['/usr/local/bin/pyls'],
" \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'],
" \ }
" nnoremap <F5> :call LanguageClient_contextMenu()<CR>
" " Or map each action separately
" nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
" nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
" nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
"*****************************************************************************
"" Macros
"*****************************************************************************
nnoremap <leader>gcr If<esc>A # rubocop:disable RSpec/Focus<esc>
nnoremap <leader>sal gg<esc>O$seeds_already_loaded = true<esc><C-o>
nnoremap <leader>gms gg<esc>O$minimal_seeds = true<esc><C-o>
"*****************************************************************************
"" Markdown
"*****************************************************************************
"Markdown plugin
" filetype plugin on
let g:vim_markdown_conceal = 0
let g:vim_markdown_conceal_code_blocks = 0
"Uncomment to override defaults:
"let g:instant_markdown_slow = 1
"let g:instant_markdown_autostart = 0
"let g:instant_markdown_open_to_the_world = 1
"let g:instant_markdown_allow_unsafe_content = 1
"let g:instant_markdown_allow_external_content = 0
"let g:instant_markdown_mathjax = 1
"let g:instant_markdown_logfile = '/tmp/instant_markdown.log'
"let g:instant_markdown_autoscroll = 0
"let g:instant_markdown_port = 8888
"let g:instant_markdown_python = 1
"MarkdownPreview
" set to 1, nvim will open the preview window after entering the markdown buffer
" default: 0
let g:mkdp_auto_start = 1
" set to 1, the nvim will auto close current preview window when change
" from markdown buffer to another buffer
" default: 1
let g:mkdp_auto_close = 1
" set to 1, the vim will refresh markdown when save the buffer or
" leave from insert mode, default 0 is auto refresh markdown as you edit or
" move the cursor
" default: 0
let g:mkdp_refresh_slow = 0
" set to 1, the MarkdownPreview command can be use for all files,
" by default it can be use in markdown file
" default: 0
let g:mkdp_command_for_global = 0
" set to 1, preview server available to others in your network
" by default, the server listens on localhost (127.0.0.1)
" default: 0
let g:mkdp_open_to_the_world = 0
" use custom IP to open preview page
" useful when you work in remote vim and preview on local browser
" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9
" default empty
let g:mkdp_open_ip = ''
" specify browser to open preview page
" default: ''
let g:mkdp_browser = ''
" set to 1, echo preview page url in command line when open preview page
" default is 0
let g:mkdp_echo_preview_url = 0
" a custom vim function name to open preview page
" this function will receive url as param
" default is empty
let g:mkdp_browserfunc = ''
" options for markdown render
" mkit: markdown-it options for render
" katex: katex options for math
" uml: markdown-it-plantuml options
" maid: mermaid options
" disable_sync_scroll: if disable sync scroll, default 0
" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle'
" middle: mean the cursor position alway show at the middle of the preview page
" top: mean the vim top viewport alway show at the top of the preview page
" relative: mean the cursor position alway show at the relative positon of the preview page
" hide_yaml_meta: if hide yaml metadata, default is 1
" sequence_diagrams: js-sequence-diagrams options
" content_editable: if enable content editable for preview page, default: v:false
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1,
\ 'sequence_diagrams': {},
\ 'flowchart_diagrams': {},
\ 'content_editable': v:false
\ }
" use a custom markdown style must be absolute path
" like '/Users/username/markdown.css' or expand('~/markdown.css')
let g:mkdp_markdown_css = ''
" use a custom highlight style must absolute path
" like '/Users/username/highlight.css' or expand('~/highlight.css')
let g:mkdp_highlight_css = ''
" use a custom port to start server or random for empty
let g:mkdp_port = ''
" preview page title
" ${name} will be replace with the file name
let g:mkdp_page_title = '「${name}」'
"*****************************************************************************
"" NERDTree
"*****************************************************************************
"" NERDTree configuration
let g:NERDTreeChDirMode=2
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let g:NERDTreeShowBookmarks=1
let g:nerdtree_tabs_focus_on_files=1
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
let g:NERDTreeWinSize = 50
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
nnoremap <silent> <F2> :NERDTreeFind<CR>
nnoremap <silent> <F3> :NERDTreeToggle<CR>
let g:NERDTreeMapOpenInTab = "l"
"Close NERDTree when you open a file
let NERDTreeQuitOnOpen = 1
"Prettify NERDTree
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
" autocmd FileType nerdtree setlocal noreadonly
"*****************************************************************************
"" polyglot
"*****************************************************************************
" Syntax highlight
" Default highlight is better than polyglot
let g:polyglot_disabled = ['python']
let python_highlight_all = 1
"*****************************************************************************
"" Python
"*****************************************************************************
" vim-python
augroup vimrc-python
autocmd!
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 colorcolumn=79
\ formatoptions+=croq softtabstop=4
\ cinwords=if,elif,else,for,while,try,except,finally,def,class,with
augroup END
"*****************************************************************************
"" jedi-vim
"*****************************************************************************
let g:jedi#popup_on_dot = 0
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_definitions_command = "<leader>d"
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#rename_command = "<leader>r"
let g:jedi#show_call_signatures = "0"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#smart_auto_mappings = 0
"*****************************************************************************
"" ripgrep
"*****************************************************************************
if executable('rg')
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
set grepprg=rg\ --vimgrep
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
endif
"*****************************************************************************
"" rspec.vim
"*****************************************************************************
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
"Prepend `bundle exec`
let g:rspec_command = "!bundle exec rspec {spec}"
"*****************************************************************************
"" Ruby
"*****************************************************************************
"Omnicomplete
let g:ruby_host_prog = '~/.rbenv/shims/neovim-ruby-host'
let g:ruby_path = system('echo $HOME/.rbenv/shims')
" ruby
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
augroup vimrc-ruby
autocmd!
autocmd BufNewFile,BufRead *.rb,*.rbw,*.gemspec setlocal filetype=ruby
autocmd FileType ruby set tabstop=2|set shiftwidth=2|set expandtab softtabstop=2
augroup END
" For ruby refactory
if has('nvim')
runtime! macros/matchit.vim
else
packadd! matchit
endif
" Ruby refactory
nnoremap <leader>rap :RAddParameter<cr>
nnoremap <leader>rcpc :RConvertPostConditional<cr>
nnoremap <leader>rel :RExtractLet<cr>
vnoremap <leader>rec :RExtractConstant<cr>
vnoremap <leader>relv :RExtractLocalVariable<cr>
nnoremap <leader>rit :RInlineTemp<cr>
vnoremap <leader>rrlv :RRenameLocalVariable<cr>
vnoremap <leader>rriv :RRenameInstanceVariable<cr>
vnoremap <leader>rem :RExtractMethod<cr>
"Run RSpec in Tmux
" map <Leader>rt :w<cr>:call RunCurrentTest('!ts be rspec')<CR>
" Thoughtbot Vim-RSpec
let g:rspec_command = "Dispatch bundle exec rspec {spec}"
" let g:rspec_command = "!bundle exec rspec {spec}"
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
" map <LocalLeader>s :e db/schema.rb<CR>
"*****************************************************************************
"" Search
"*****************************************************************************
"" Clean search (highlight)
nnoremap <silent> <leader><space> :noh<cr>
"" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
set fileformats=unix,dos,mac
if exists('$SHELL')
set shell=$SHELL
else
set shell=/bin/sh
endif
"Search for visually selected text
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
"*****************************************************************************
"" Session Management
"*****************************************************************************
nnoremap <leader>so :OpenSession<Space>
nnoremap <leader>ss :SaveSession<Space>
nnoremap <leader>sd :DeleteSession<CR>
nnoremap <leader>sc :CloseSession<CR>
let g:session_directory = "~/.config/nvim/session"
let g:session_autoload = "no"
let g:session_autosave = "yes"
let g:session_autosave_periodic = 1
let g:session_command_aliases = 1
let g:session_autosave_silent = 1
"*****************************************************************************
"" The Silver Searcher
"*****************************************************************************
if executable('ag')
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
set grepprg=ag\ --nogroup\ --nocolor
endif
let g:startify_session_dir = '~/.config/nvim/session'
let g:startify_lists = [
\ { 'type': 'files', 'header': [' Files'] },
\ { 'type': 'dir', 'header': [' Current Directory '. getcwd()] },
\ { 'type': 'sessions', 'header': [' Sessions'] },
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
\ ]
let g:startify_bookmarks = [
\ { 'i': '~/.config/nvim/init.vim' },
\ '~/Development/inspiregroup/chameleon/creator/services/creator-backend',
\ '~/Development/publish/clockworkpc.github.io',
\ '~/Development/inspiregroup/chameleon/collect',
\ ]
let g:startify_session_autoload = 1
let g:startify_fortune_use_unicode = 1
let g:startify_session_persistence = 1
let g:startify_enable_special = 0
"*****************************************************************************
"" Tagbar
"*****************************************************************************
nmap <silent> <F4> :TagbarToggle<CR>
let g:tagbar_autofocus = 1
let g:tagbar_type_ruby = {
\ 'kinds' : [
\ 'm:modules',
\ 'c:classes',
\ 'd:describes',
\ 'C:contexts',
\ 'f:methods',
\ 'F:singleton methods'
\ ]
\ }
"*****************************************************************************
"" Terminal Emulation
"*****************************************************************************
" terminal emulation
nnoremap <silent> <leader>sh :terminal<CR>
"Open a terminal in a new tab
map <silent> <M-C-N> :tabnew <bar> :terminal<CR>
"*****************************************************************************
"" textobj-rubyblock
"*****************************************************************************
runtime macros/matchit.vim
set nocompatible
if has("autocmd")
filetype indent plugin on
endif
let g:textobj_ruby_more_mappings = 1
"*****************************************************************************
"" Typescript
"*****************************************************************************
" typescript
let g:yats_host_keyword = 1
"*****************************************************************************
"" UltiSnips
"*****************************************************************************
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
" let g:UltiSnipsExpandTrigger="<tab>"
" let g:UltiSnipsJumpForwardTrigger="<c-b>"
" let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" let g:UltiSnipsEditSplit="vertical"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
let g:UltiSnipsEditSplit="vertical"
" let g:UltiSnipsSnippetDirectories=["UltiSnips", "myUltiSnips"]
"*****************************************************************************
"" vim-airline
"*****************************************************************************
let g:airline_theme = 'powerlineish'
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline#extensions#tagbar#enabled = 1
let g:airline_skip_empty_sections = 1
"python
let g:airline#extensions#virtualenv#enabled = 1
"*****************************************************************************
"" Vimroom
"*****************************************************************************
"Vimroom
let g:goyo_width=100
let g:goyo_margin_top = 2
let g:goyo_margin_bottom = 2
nnoremap <silent> <leader>z :Goyo<cr>
"*****************************************************************************
"" vim-ruby-doc
"*****************************************************************************
" For some reason this plugin doesn't work anymore,
" so I hacked together the same functionality, using its example.
" Replace 'firefox' with whatever command you need instead.
let g:ruby_doc_url_template="http://rubydoc.info/search/stdlib/core?q=%"
let g:rails_doc_url_template="http://api.rubyonrails.org/?q=%"
let g:rspec_doc_url_template='https://www.relishapp.com/rspec/search?query=%'
function! AnyRDoc(url_template)
if &ft =~ "ruby"
else
return
endif
let s:wordUnderCursor = expand("<cword>")
let s:url = substitute(a:url_template, "%", s:wordUnderCursor, "g")
let s:cmd = "!firefox \"" . s:url . "\""
execute s:cmd
endfunction
map RB :call AnyRDoc(ruby_doc_url_template)<CR>
map RR :call AnyRDoc(rails_doc_url_template)<CR>
map RS :call AnyRDoc(rspec_doc_url_template)<CR>
let g:vimwiki_list = [{'path': '~/Development/PanhandleDoorDocuments/', 'path_html': '~/public_html/'}]
"*****************************************************************************
"" visualbell
"*****************************************************************************
" Disable visualbell
set noerrorbells visualbell t_vb=
if has('autocmd')
autocmd GUIEnter * set visualbell t_vb=
endif
"*****************************************************************************
"" Visual Mode
"*****************************************************************************
"" Vmap for maintain Visual Mode after shifting > and <
vmap < <gv
vmap > >gv
"" Move visual block
" vnoremap J :m '>+1<CR>gv=gv
" vnoremap K :m '<-2<CR>gv=gv
"*****************************************************************************
"" Visual Settings
"*****************************************************************************
syntax on
set ruler
set number
let no_buffers_menu=1
set mousemodel=popup
set t_Co=256
set guioptions=egmrti
set gfn=Monospace\ 10
if has("gui_running")
if has("gui_mac") || has("gui_macvim")
set guifont=Menlo:h12
set transparency=7
endif
else
let g:CSApprox_loaded = 1
" IndentLine
let g:indentLine_enabled = 1
let g:indentLine_concealcursor = 0
let g:indentLine_char = '┆'
let g:indentLine_faster = 1
endif
"" Disable the blinking cursor.
set gcr+=a:blinkon0
set scrolloff=3
"" Status bar
set laststatus=2
"" Use modeline overrides
set modeline
set modelines=10
set title
set titleold="Terminal"
set titlestring=%F
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
if exists("*fugitive#statusline")
set statusline+=%{fugitive#statusline()}
endif
"*****************************************************************************
"" XML
"*****************************************************************************
function! DoFormatXML()
:%s/></>\r</g
:0
=:$
endfunction
com! FormatXML call DoFormatXML()
"*****************************************************************************
"" YAML
"*****************************************************************************
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
set foldlevelstart=20
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'
" let g:ale_lint_on_text_changed = 'never'
"*****************************************************************************
"" CPC NEOVIM CONFIGURATION
"" Maintainer: Alexander JK Garber
"*****************************************************************************
"*****************************************************************************
"" Vim-PLug core
"*****************************************************************************
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
let g:vim_bootstrap_langs = "go,haskell,html,javascript,lisp,python,ruby,typescript"
let g:vim_bootstrap_editor = "nvim" " nvim or 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
" Required:
call plug#begin(expand('~/.config/nvim/plugged'))
"****************************************************************************
"" Project
"****************************************************************************
" Functional Start Screen
" Plug 'mhinz/vim-startify'
" Treeview file browser in VIM
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
" Plug 'MarSoft/nerdtree-grep-plugin'
" Status bar above and below
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Show changed lines in gutter
Plug 'airblade/vim-gitgutter'
" Search for strings in files
Plug 'vim-scripts/grep.vim'
"GVim-only colour schemes
Plug 'vim-scripts/CSApprox'
" Fuzzy file search
if isdirectory('/usr/local/opt/fzf')
Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
else
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
endif
let g:make = 'gmake'
if exists('make')
let g:make = 'make'
endif
" Find and Replace
Plug 'brooth/far.vim'
" Interactive command execution
Plug 'Shougo/vimproc.vim', {'do': g:make}
"" Vim-Session
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'
" ctags
" Plug 'ludovicchabant/vim-gutentags'
" Plug 'craigemery/vim-autotag'
"codequery
" Plug 'Shougo/unite.vim'
" Plug 'devjoe/vim-codequery'
"grep replace
Plug 'skwp/greplace.vim'
"view images
Plug 'ashisha/image.vim'
"Reload files changed on disk
Plug 'djoshea/vim-autoread'
" Fountain plugin
Plug 'kblin/vim-fountain'
" Close buffers
Plug 'Asheq/close-buffers.vim'
" Conquer of Code (Autocomplete)
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Autosave sessions
Plug 'tpope/vim-obsession'
"Use Vim in the browser
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
"****************************************************************************
"" Editor (NORMAL MODE ONLY)
"****************************************************************************
" Comment out lines with gcc or gc in visual mode
Plug 'tpope/vim-commentary'
" Tag viewer for class and method definitions
Plug 'majutsushi/tagbar'
" Display thin vertical lines for indentations
Plug 'Yggdroot/indentLine'
" Repeat a plug-in command
Plug 'tpope/vim-repeat'
" Improved clipping of text
Plug 'svermeulen/vim-easyclip'
"Replace double quotes, single quotes, etc
Plug 'tpope/vim-surround'
"Split single line to multiline and visa versa
Plug 'AndrewRadev/splitjoin.vim'
"Word Motion
" Plug 'chaoren/vim-wordmotion'
"Resize Windows
Plug 'simeji/winresizer'
"****************************************************************************
"" Editor (INSERT MODE ONLY)
"****************************************************************************
"Autocomplete
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'ervandew/supertab'
"Snippets
Plug 'sirver/UltiSnips'
Plug 'honza/vim-snippets'
" Autocomplete brackets, quotes, etc.
Plug 'Raimondi/delimitMate'
"Markdown tables
Plug 'dhruvasagar/vim-table-mode'
"
"Pairs of handy bracket mappings
Plug 'tpope/vim-unimpaired'
"Horizontal navigation"
Plug 'unblevable/quick-scope'
"Automatic bullet and numbered lists
Plug 'dkarter/bullets.vim'
"Automatic newline and indentation between brackets
Plug 'jiangmiao/auto-pairs'
"Merge git conflicts
Plug 'christoomey/vim-conflicted'
"****************************************************************************
"" Editor (VISUAL MODE ONLY)
"****************************************************************************
"Select a ruby block in VISUAL mode
Plug 'nelstrom/vim-textobj-rubyblock'
" dependency of vim-textobj-rubyblock
Plug 'kana/vim-textobj-user'
"Scratch buffer
" Plug 'mtth/scratch.vim'
"****************************************************************************
"" Editor (COMBINED MODES)
"****************************************************************************
"Make Goyo even nicer
Plug 'amix/vim-zenroom2'
"Code linting
Plug 'dense-analysis/ale'
Plug 'prettier/vim-prettier'
"OrgMode for VIM
Plug 'jceb/vim-orgmode'
"Atomesque coloures
Plug 'joshdick/onedark.vim'
"Distraction-free editing
Plug 'junegunn/goyo.vim'
"Markdown preview
" Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
" Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
" Plug 'iamcco/markdown-preview.nvim'
Plug 'suan/vim-instant-markdown', {'for': 'markdown', 'do': 'yarn install'}
"Floating Terminal
Plug 'voldikss/vim-floaterm'
"Cucumber syntax highlighting
Plug 'barboza/vim-cucumber-string-highlight'
""****************************************************************************
"" Version Control
"****************************************************************************
" Git wrapper
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb' " required by fugitive to :Gbrowse
" GraphQL syntax highlighting
Plug 'jparise/vim-graphql'
"***************************************************************************
"" Ruby and Rails
"***************************************************************************
"Refactor
Plug 'ecomba/vim-ruby-refactoring'
Plug 'thoughtbot/vim-rspec'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-cucumber'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-rake'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-rbenv'
Plug 'thoughtbot/vim-rspec'
Plug 'vim-ruby/vim-ruby'
"Ruby/Rails/RSpec documentation
" Plug 'lucapette/vim-ruby-doc'
" Toggle Ruby do/end and {}
Plug 'jgdavey/vim-blockle'
"***************************************************************************
"" Other Languages
"***************************************************************************
" go
"" Go Lang Bundle
Plug 'fatih/vim-go', {'do': ':GoInstallBinaries'}
" haskell
"" Haskell Bundle
Plug 'eagletmt/neco-ghc'
Plug 'dag/vim2hs'
Plug 'pbrisbin/vim-syntax-shakespeare'
" html
"" HTML Bundle
Plug 'hail2u/vim-css3-syntax'
" Plug 'gorodinskiy/vim-coloresque'
Plug 'tpope/vim-haml'
Plug 'mattn/emmet-vim'
Plug 'zeekay/vim-beautify'
" javascript
"" Javascript Bundle
Plug 'jelera/vim-javascript-syntax'
" lisp
"" Lisp Bundle
Plug 'vim-scripts/slimv.vim'
" python
"" Python Bundle
Plug 'davidhalter/jedi-vim'
Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'}
" typescript
Plug 'leafgarland/typescript-vim'
Plug 'HerringtonDarkholme/yats.vim'
"VimBeGood (Primeagen)
" Plug 'ThePrimeagen/vim-be-good', {'do': './install.sh'}
"FISH Scripting
Plug 'dag/vim-fish'
"Writing Tools
Plug 'preservim/vim-pencil'
Plug 'dbmrq/vim-ditto'
Plug 'honza/writer.vim'
Plug 'mattn/vim-metarw-gdrive'
" Plug 'vimwiki/vimwiki'
Plug 'vim-latex/vim-latex'
Plug 'kblin/vim-fountain'
"*****************************************************************************
call plug#end()
"***************************************************************************
"" Core VIM Keybindings
"***************************************************************************"
" Map leader to ,
let mapleader=','
"map LocalLeader to \\
let maplocalleader = "\\"
"Left (h) => [h]
noremap h h
"Up (j) => [t]
noremap t gj
"Down (k) => [n]
noremap n gk
"Right (l) => [s]
noremap s l
"End of line ($) => [-]
noremap - $
"Start of line (^) => [_]
noremap _ ^
"Jump to letter before (t) => [j]
noremap k t
"Sentences
noremap $ s
"m is shadowed by easyclip plugin
noremap gm m
" j/J moves between search mappings
nnoremap j n
nnoremap J N
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
" nnoremap j nzzzv
" nnoremap J Nzzzv
"Move text down
nnoremap <A-t> :m .+1<CR>==
inoremap <A-t> <Esc>:m .+1<CR>==gi
vnoremap <A-t> :m '>+1<CR>gv=gv
"Move text up
nnoremap <A-n> :m .-2<CR>==
inoremap <A-n> <Esc>:m .-2<CR>==gi
vnoremap <A-n> :m '<-2<CR>gv=gv
"*****************************************************************************
"" Mappings
"*****************************************************************************
"" Split
noremap <Leader>h :<C-u>split<CR>
" New buffer rather than the current file
noremap <Leader>v :<C-u>vnew<CR>
" Current file rather than a new buffer
" noremap <Leader>v :<C-u>vsplit<CR>
"*****************************************************************************
"Customised VIM
"*****************************************************************************
"Show how many lines yanked, inter alia
set report=0
"Hybrid line numbers
:set number relativenumber
:augroup numbertoggle
: autocmd!
: autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
: autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
:augroup END
"More natural movement in INSERT mode
behave mswin
"*****************************************************************************
"" Custom Bindings
"*****************************************************************************
"Fix indentation for the whole file
nnoremap <F7> gg=G<C-o><C-o>
" Bind F8 to fixing problems with ALE
nmap <F8> <Plug>(ale_fix)
"Force filetype 'yaml' for yml files
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml foldmethod=manual
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" autocmd BufNewFile,BufRead *.yml set ft=yaml
"Stop line wrap from breaking words
set linebreak
"Skip out of brackets
inoremap <C-e> <C-o>A
"Replace all
nnoremap S :%s///g<Left><Left><Left>
"Jump to next occurrence in INSERT mode
imap <C-j> <Esc>jcaw
"Replace all within a visual selection
" vnoremap S :s/\%V//g<Left><Left><Left>
"Ctrl-A for select all
" vnnoremap <C-a> ggVG
"Replace all matching strings in visual selection
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
" Close all hidden buffers
nnoremap <silent> <C-q> :Bdelete menu<CR>
function! ALEFixFast()
syntax off
exec "ALEFix"
syntax on
endfunction
"Save file, even if no changes
nor <silent> <Leader>w :w<CR>
vnoremap <silent> <C-w> <C-C>:update<CR>
"Close all buffers and quit Neovim
noremap <Leader>' :qall<CR>
"*****************************************************************************
"" Abbreviations
"*****************************************************************************
"" no one is really happy until you have this shortcuts
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall
"*****************************************************************************
"" ALE
"*****************************************************************************
" LINTERS
let g:ale_linters = {
\ 'gql': ['prettier'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\ 'vim': ['vint'],
\}
function! SettingsTurnOff()
"Turns syntax off only in current buffer
exec "syntax clear"
" exec "set nocursorcolumn"
" exec "set nocursorline"
" exec "set norelativenumber"
endfunction
function! SettingsTurnOn()
exec "syntax on"
" exec "set number relativenumber"
exec "AirlineRefresh"
endfunction
augroup YourGroup
autocmd!
autocmd User ALEFixPre call SettingsTurnOff()
autocmd User ALEFixPost call SettingsTurnOn()
augroup END
" FIXERS
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'json': ['jq'],
\}
let g:ale_lint_on_enter = 1
let g:ale_completion_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %(code): %%s [%severity%]'
let g:airline#extensions#ale#enabled = 1
" let g:ale_ruby_rubocop_executable = 'rubocop-daemon exec -- --auto-correct'
" set omnifunc=ale#completion#OmniFunc
"*****************************************************************************
"" Autocmd Rules, Functions
"*****************************************************************************
"" Functions
if !exists('*s:setupWrapping')
function s:setupWrapping()
set wrap
set wm=2
set textwidth=80
endfunction
endif
"*****************************************************************************
"" Autocmd Rules
"*****************************************************************************
"" The PC is fast enough, do syntax highlight syncing from start unless 200 lines
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=200
augroup END
"" Remember cursor position
augroup vimrc-remember-cursor-position
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
"" txt
augroup vimrc-wrapping
autocmd!
autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
augroup END
"" make/cmake
augroup vimrc-make-cmake
autocmd!
autocmd FileType make setlocal noexpandtab
autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
augroup END
set autoread
"*****************************************************************************
"" AUTO PAIRS
"*****************************************************************************
" Jump outside '"({
if !exists('g:AutoPairsShortcutJump')
let g:AutoPairsShortcutJump = '<C-l>'
endif
"*****************************************************************************
"" Buffers, Tabs, Windows
"*****************************************************************************
"" Buffer nav
noremap <leader>x :bn<CR>
"" Close buffer
noremap <leader>c :bd<CR>
"" Enable hidden buffers
" set hidden
"" Switching windows
noremap <C-h> <C-w>h
noremap <C-t> <C-w>j
noremap <C-n> <C-w>k
noremap <C-s> <C-w>l
"" Tabs
nnoremap <Tab> gt
nnoremap <S-Tab> gT
nnoremap <silent> <S-t> :tabnew<CR>
"Scratch buffer
function! Scratch()
tabnew
noswapfile hide enew
setlocal buftype=nofile
setlocal bufhidden=hide
"setlocal nobuflisted
"lcd ~
file scratch
endfunction
"*****************************************************************************
"" COC
"*****************************************************************************
" 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
" let g:coc_global_extensions = ['coc-solargraph']
"*****************************************************************************
"" Copy/Paste/Cut
"*****************************************************************************
if has('unnamedplus')
set clipboard=unnamed,unnamedplus
endif
noremap YY "+y<CR>
noremap <leader>p "+gP<CR>
noremap XX "+x<CR>
if has('macunix')
" pbcopy for OSX copy/paste
vmap <C-x> :!pbcopy<CR>
vmap <C-c> :w !pbcopy<CR><CR>
endif
"*****************************************************************************
"" deoplete
"*****************************************************************************
""deoplete
let g:deoplete#enable_at_startup = 1
let g:auto_complete_popup = "manual"
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ deoplete#mappings#manual_complete()
function! s:check_back_space() abort "{{{
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction"}}}
"*****************************************************************************
"" neosnippet
"*****************************************************************************
" " Plugin key-mappings.
" " Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <C-k> <Plug>(neosnippet_expand_or_jump)
" smap <C-k> <Plug>(neosnippet_expand_or_jump)
" xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
" imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
" if has('conceal')
" set conceallevel=2 concealcursor=niv
" endif
" " To use Honza's Vim Snippets
" let g:neosnippet#snippets_directory='~/.config/nvim/plugged/vim-snippets/snippets'
"*****************************************************************************
"" Encoding
"*****************************************************************************
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
let g:far#enable_undo=1
"*****************************************************************************
"" fish
"*****************************************************************************
if &shell =~# 'fish$'
set shell=sh
endif
"*****************************************************************************
"" fzf
"*****************************************************************************
set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
let $FZF_DEFAULT_COMMAND = "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'dist/**' -prune -o -type f -print -o -type l -print 2> /dev/null"
" nnoremap <silent> <leader>b :Buffers<CR>
nnoremap <silent> <leader>e :FZF -m<CR>
"Recovery commands from history through FZF
nmap <leader>y :History:<CR>
"NOTE: To open a file in a new tab CTRL-V, CTRL-X, or CTRL-T
"*****************************************************************************
"" General Settings
"*****************************************************************************
"Use `onedark` colour scheme
" colorscheme onedark
colo onedark
"Syntax highlighting from start unless 1000 lines (instead of 200)
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync maxlines=1000
augroup END
"Refresh file when changed on disk
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI *
\ if mode() !~ '\v(c|r.?|!|t)' && getcmdwintype() == '' | checktime | endif
"Autowrite
set autowriteall
" :set tabstop=2
" :set shiftwidth=2
" :set expandtab
" Folding
set fdm=syntax
set nofoldenable
" set foldlevel=0
" Built-in Neovim autocomplete
cnoremap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
"NERDTree can modify files
set modifiable
"Add Cucumber filetype detection
au BufRead,BufNewFile *.cucumber set filetype=cucumber
"Various completion plugins require this
filetype plugin on
"Omni completion
" set omnifunc=syntaxcomplete#Complete
"Spell check
nnoremap <F10> :set spell! spelllang=en_gb,lt,fr,he!<CR>
"Center screen when going into INSERT mode
" autocmd InsertEnter * norm zz
"Thin line cursor in INSERT mode
highlight Cursor guifg=white guibg=black
highlight iCursor guifg=white guibg=steelblue
set guicursor=n-v-c:block-Cursor
set guicursor=i:ver25-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait10
"Highlight current line
autocmd InsertEnter,InsertLeave * set cul!
"Auotmatically split to the right
set splitright
"Vim LateX settings
let g:tex_flavor='latex'
let g:python3_host_prog = '/usr/bin/python3'
let g:python_host_prog = '/usr/bin/python2'
"*****************************************************************************
"" Git
"*****************************************************************************
noremap <Leader>ga :Gwrite<CR>
noremap <Leader>gc :Gcommit<CR>
noremap <Leader>gsh :Gpush<CR>
noremap <Leader>gll :Gpull<CR>
noremap <Leader>gs :Gstatus<CR>
noremap <Leader>gb :Gblame<CR>
noremap <Leader>gd :Gvdiff<CR>
noremap <Leader>gr :Gremove<CR>
"" Open current line on GitHub
nnoremap <Leader>o :.Gbrowse<CR>
set diffopt+=vertical
"*****************************************************************************
"" Go Language
"*****************************************************************************
" autocmd BufWritePost *.go !go test
"*****************************************************************************
"" grep.vim
"*****************************************************************************
" grep.vim
nnoremap <silent> <leader>f :Rgrep<CR>
let Grep_Default_Options = '-IR'
let Grep_Skip_Files = '*.log *.db'
let Grep_Skip_Dirs = '.git node_modules'
"*****************************************************************************
"" HTML
"*****************************************************************************
" for html files, 2 spaces
autocmd Filetype html setlocal ts=2 sw=2 expandtab
"View HTML Text
function! ViewHtmlText(url)
if !empty(a:url)
new
setlocal buftype=nofile bufhidden=hide noswapfile
execute 'r !elinks ' . a:url . ' -dump -dump-width ' . winwidth(0)
1d
endif
endfunction
" Save and view text for current html file.
nnoremap <Leader>H :update<Bar>call ViewHtmlText(expand('%:p'))<CR>
" " View text for visually selected url.
vnoremap <Leader>h y:call ViewHtmlText(@*)<CR>
" View text for URL from clipboard.
" On Linux, use @* for current selection or @+ for text in clipboard.
nnoremap <Leader>h :call ViewHtmlText(@+)<CR>
"*****************************************************************************
"" Emmet
"*****************************************************************************
" let g:user_emmet_install_global = 0
" autocmd FileType html,css,erb EmmetInstall
let g:user_emmet_leader_key=','
"*****************************************************************************
"" Indentations, Tabs, Whitespaces
"*****************************************************************************
"" Fix backspace indent
set backspace=indent,eol,start
"" Tabs. May be overridden by autocmd rules
set tabstop=2
set softtabstop=0
set shiftwidth=2
set expandtab
" remove trailing whitespaces
command! FixWhitespace :%s/\s\+$//e
"Fix indentation for the whole file
" nnoremap <F7> gg=G<C-o><C-o>
"*****************************************************************************
"" JavaScript
"*****************************************************************************
" javascript
let g:javascript_enable_domhtmlcss = 1
" vim-javascript
augroup vimrc-javascript
autocmd!
autocmd FileType javascript setl tabstop=4|setl shiftwidth=4|setl expandtab softtabstop=4
augroup END
"*****************************************************************************
"" LanguageClient-Neovim
"*****************************************************************************
" Tell the language client to use the default IP and port
" that Solargraph runs on
" let g:LanguageClient_serverCommands = {
" \ 'ruby': ['tcp://localhost:7658']
" \ }
" Don't send a stop signal to the server when exiting vim.
" This is optional, but I don't like having to restart Solargraph
" every time I restart vim.
" let g:LanguageClient_autoStop = 0
" Configure ruby omni-completion to use the language client:
" autocmd FileType ruby setlocal omnifunc=LanguageClient#complete
" Required for operations modifying multiple buffers like rename.
" set hidden
" let g:LanguageClient_serverCommands = {
" \ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
" \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
" \ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
" \ 'python': ['/usr/local/bin/pyls'],
" \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'],
" \ }
" nnoremap <F5> :call LanguageClient_contextMenu()<CR>
" " Or map each action separately
" nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
" nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
" nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
"*****************************************************************************
"" Macros
"*****************************************************************************
nnoremap <leader>gcr If<esc>A # rubocop:disable RSpec/Focus<esc>
nnoremap <leader>sal gg<esc>O$seeds_already_loaded = true<esc><C-o>
nnoremap <leader>gms gg<esc>O$minimal_seeds = true<esc><C-o>
"*****************************************************************************
"" Markdown
"*****************************************************************************
"Markdown plugin
" filetype plugin on
let g:vim_markdown_conceal = 0
let g:vim_markdown_conceal_code_blocks = 0
"Uncomment to override defaults:
"let g:instant_markdown_slow = 1
"let g:instant_markdown_autostart = 0
"let g:instant_markdown_open_to_the_world = 1
"let g:instant_markdown_allow_unsafe_content = 1
"let g:instant_markdown_allow_external_content = 0
"let g:instant_markdown_mathjax = 1
"let g:instant_markdown_logfile = '/tmp/instant_markdown.log'
"let g:instant_markdown_autoscroll = 0
"let g:instant_markdown_port = 8888
"let g:instant_markdown_python = 1
"MarkdownPreview
" set to 1, nvim will open the preview window after entering the markdown buffer
" default: 0
let g:mkdp_auto_start = 1
" set to 1, the nvim will auto close current preview window when change
" from markdown buffer to another buffer
" default: 1
let g:mkdp_auto_close = 1
" set to 1, the vim will refresh markdown when save the buffer or
" leave from insert mode, default 0 is auto refresh markdown as you edit or
" move the cursor
" default: 0
let g:mkdp_refresh_slow = 0
" set to 1, the MarkdownPreview command can be use for all files,
" by default it can be use in markdown file
" default: 0
let g:mkdp_command_for_global = 0
" set to 1, preview server available to others in your network
" by default, the server listens on localhost (127.0.0.1)
" default: 0
let g:mkdp_open_to_the_world = 0
" use custom IP to open preview page
" useful when you work in remote vim and preview on local browser
" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9
" default empty
let g:mkdp_open_ip = ''
" specify browser to open preview page
" default: ''
let g:mkdp_browser = ''
" set to 1, echo preview page url in command line when open preview page
" default is 0
let g:mkdp_echo_preview_url = 0
" a custom vim function name to open preview page
" this function will receive url as param
" default is empty
let g:mkdp_browserfunc = ''
" options for markdown render
" mkit: markdown-it options for render
" katex: katex options for math
" uml: markdown-it-plantuml options
" maid: mermaid options
" disable_sync_scroll: if disable sync scroll, default 0
" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle'
" middle: mean the cursor position alway show at the middle of the preview page
" top: mean the vim top viewport alway show at the top of the preview page
" relative: mean the cursor position alway show at the relative positon of the preview page
" hide_yaml_meta: if hide yaml metadata, default is 1
" sequence_diagrams: js-sequence-diagrams options
" content_editable: if enable content editable for preview page, default: v:false
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1,
\ 'sequence_diagrams': {},
\ 'flowchart_diagrams': {},
\ 'content_editable': v:false
\ }
" use a custom markdown style must be absolute path
" like '/Users/username/markdown.css' or expand('~/markdown.css')
let g:mkdp_markdown_css = ''
" use a custom highlight style must absolute path
" like '/Users/username/highlight.css' or expand('~/highlight.css')
let g:mkdp_highlight_css = ''
" use a custom port to start server or random for empty
let g:mkdp_port = ''
" preview page title
" ${name} will be replace with the file name
let g:mkdp_page_title = '「${name}」'
"*****************************************************************************
"" NERDTree
"*****************************************************************************
"" NERDTree configuration
let g:NERDTreeChDirMode=2
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let g:NERDTreeShowBookmarks=1
let g:nerdtree_tabs_focus_on_files=1
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
let g:NERDTreeWinSize = 50
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
nnoremap <silent> <F2> :NERDTreeFind<CR>
nnoremap <silent> <F3> :NERDTreeToggle<CR>
let g:NERDTreeMapOpenInTab = "l"
"Close NERDTree when you open a file
let NERDTreeQuitOnOpen = 1
"Prettify NERDTree
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
" autocmd FileType nerdtree setlocal noreadonly
"*****************************************************************************
"" polyglot
"*****************************************************************************
" Syntax highlight
" Default highlight is better than polyglot
let g:polyglot_disabled = ['python']
let python_highlight_all = 1
"*****************************************************************************
"" Python
"*****************************************************************************
" vim-python
augroup vimrc-python
autocmd!
autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 colorcolumn=79
\ formatoptions+=croq softtabstop=4
\ cinwords=if,elif,else,for,while,try,except,finally,def,class,with
augroup END
"*****************************************************************************
"" jedi-vim
"*****************************************************************************
let g:jedi#popup_on_dot = 0
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_definitions_command = "<leader>d"
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#rename_command = "<leader>r"
let g:jedi#show_call_signatures = "0"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#smart_auto_mappings = 0
"*****************************************************************************
"" ripgrep
"*****************************************************************************
if executable('rg')
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
set grepprg=rg\ --vimgrep
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
endif
"*****************************************************************************
"" rspec.vim
"*****************************************************************************
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
"Prepend `bundle exec`
let g:rspec_command = "!bundle exec rspec {spec}"
"*****************************************************************************
"" Ruby
"*****************************************************************************
"Omnicomplete
let g:ruby_host_prog = '~/.rbenv/shims/neovim-ruby-host'
let g:ruby_path = system('echo $HOME/.rbenv/shims')
" ruby
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
augroup vimrc-ruby
autocmd!
autocmd BufNewFile,BufRead *.rb,*.rbw,*.gemspec setlocal filetype=ruby
autocmd FileType ruby set tabstop=2|set shiftwidth=2|set expandtab softtabstop=2
augroup END
" For ruby refactory
if has('nvim')
runtime! macros/matchit.vim
else
packadd! matchit
endif
" Ruby refactory
nnoremap <leader>rap :RAddParameter<cr>
nnoremap <leader>rcpc :RConvertPostConditional<cr>
nnoremap <leader>rel :RExtractLet<cr>
vnoremap <leader>rec :RExtractConstant<cr>
vnoremap <leader>relv :RExtractLocalVariable<cr>
nnoremap <leader>rit :RInlineTemp<cr>
vnoremap <leader>rrlv :RRenameLocalVariable<cr>
vnoremap <leader>rriv :RRenameInstanceVariable<cr>
vnoremap <leader>rem :RExtractMethod<cr>
"Run RSpec in Tmux
" map <Leader>rt :w<cr>:call RunCurrentTest('!ts be rspec')<CR>
" Thoughtbot Vim-RSpec
let g:rspec_command = "Dispatch bundle exec rspec {spec}"
" let g:rspec_command = "!bundle exec rspec {spec}"
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
" map <LocalLeader>s :e db/schema.rb<CR>
"*****************************************************************************
"" Search
"*****************************************************************************
"" Clean search (highlight)
nnoremap <silent> <leader><space> :noh<cr>
"" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
set fileformats=unix,dos,mac
if exists('$SHELL')
set shell=$SHELL
else
set shell=/bin/sh
endif
"Search for visually selected text
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
"*****************************************************************************
"" Session Management
"*****************************************************************************
nnoremap <leader>so :OpenSession<Space>
nnoremap <leader>ss :SaveSession<Space>
nnoremap <leader>sd :DeleteSession<CR>
nnoremap <leader>sc :CloseSession<CR>
let g:session_directory = "~/.config/nvim/session"
let g:session_autoload = "no"
let g:session_autosave = "yes"
let g:session_autosave_periodic = 1
let g:session_command_aliases = 1
let g:session_autosave_silent = 1
"*****************************************************************************
"" The Silver Searcher
"*****************************************************************************
if executable('ag')
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
set grepprg=ag\ --nogroup\ --nocolor
endif
let g:startify_session_dir = '~/.config/nvim/session'
let g:startify_lists = [
\ { 'type': 'files', 'header': [' Files'] },
\ { 'type': 'dir', 'header': [' Current Directory '. getcwd()] },
\ { 'type': 'sessions', 'header': [' Sessions'] },
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
\ ]
let g:startify_bookmarks = [
\ { 'i': '~/.config/nvim/init.vim' },
\ '~/Development/inspiregroup/chameleon/creator/services/creator-backend',
\ '~/Development/publish/clockworkpc.github.io',
\ '~/Development/inspiregroup/chameleon/collect',
\ ]
let g:startify_session_autoload = 1
let g:startify_fortune_use_unicode = 1
let g:startify_session_persistence = 1
let g:startify_enable_special = 0
"*****************************************************************************
"" Tagbar
"*****************************************************************************
nmap <silent> <F4> :TagbarToggle<CR>
let g:tagbar_autofocus = 1
let g:tagbar_type_ruby = {
\ 'kinds' : [
\ 'm:modules',
\ 'c:classes',
\ 'd:describes',
\ 'C:contexts',
\ 'f:methods',
\ 'F:singleton methods'
\ ]
\ }
"*****************************************************************************
"" Terminal Emulation
"*****************************************************************************
" terminal emulation
nnoremap <silent> <leader>sh :terminal<CR>
"Open a terminal in a new tab
map <silent> <M-C-N> :tabnew <bar> :terminal<CR>
"*****************************************************************************
"" textobj-rubyblock
"*****************************************************************************
runtime macros/matchit.vim
set nocompatible
if has("autocmd")
filetype indent plugin on
endif
let g:textobj_ruby_more_mappings = 1
"*****************************************************************************
"" Typescript
"*****************************************************************************
" typescript
let g:yats_host_keyword = 1
"*****************************************************************************
"" UltiSnips
"*****************************************************************************
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
" let g:UltiSnipsExpandTrigger="<tab>"
" let g:UltiSnipsJumpForwardTrigger="<c-b>"
" let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" let g:UltiSnipsEditSplit="vertical"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
let g:UltiSnipsEditSplit="vertical"
" let g:UltiSnipsSnippetDirectories=["UltiSnips", "myUltiSnips"]
"*****************************************************************************
"" vim-airline
"*****************************************************************************
let g:airline_theme = 'powerlineish'
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline#extensions#tagbar#enabled = 1
let g:airline_skip_empty_sections = 1
"python
let g:airline#extensions#virtualenv#enabled = 1
"*****************************************************************************
"" Vimroom
"*****************************************************************************
"Vimroom
let g:goyo_width=100
let g:goyo_margin_top = 2
let g:goyo_margin_bottom = 2
nnoremap <silent> <leader>z :Goyo<cr>
"*****************************************************************************
"" vim-ruby-doc
"*****************************************************************************
" For some reason this plugin doesn't work anymore,
" so I hacked together the same functionality, using its example.
" Replace 'firefox' with whatever command you need instead.
let g:ruby_doc_url_template="http://rubydoc.info/search/stdlib/core?q=%"
let g:rails_doc_url_template="http://api.rubyonrails.org/?q=%"
let g:rspec_doc_url_template='https://www.relishapp.com/rspec/search?query=%'
function! AnyRDoc(url_template)
if &ft =~ "ruby"
else
return
endif
let s:wordUnderCursor = expand("<cword>")
let s:url = substitute(a:url_template, "%", s:wordUnderCursor, "g")
let s:cmd = "!firefox \"" . s:url . "\""
execute s:cmd
endfunction
map RB :call AnyRDoc(ruby_doc_url_template)<CR>
map RR :call AnyRDoc(rails_doc_url_template)<CR>
map RS :call AnyRDoc(rspec_doc_url_template)<CR>
let g:vimwiki_list = [{'path': '~/Development/PanhandleDoorDocuments/', 'path_html': '~/public_html/'}]
"*****************************************************************************
"" visualbell
"*****************************************************************************
" Disable visualbell
set noerrorbells visualbell t_vb=
if has('autocmd')
autocmd GUIEnter * set visualbell t_vb=
endif
"*****************************************************************************
"" Visual Mode
"*****************************************************************************
"" Vmap for maintain Visual Mode after shifting > and <
vmap < <gv
vmap > >gv
"" Move visual block
" vnoremap J :m '>+1<CR>gv=gv
" vnoremap K :m '<-2<CR>gv=gv
"*****************************************************************************
"" Visual Settings
"*****************************************************************************
syntax on
set ruler
set number
let no_buffers_menu=1
set mousemodel=popup
set t_Co=256
set guioptions=egmrti
set gfn=Monospace\ 10
if has("gui_running")
if has("gui_mac") || has("gui_macvim")
set guifont=Menlo:h12
set transparency=7
endif
else
let g:CSApprox_loaded = 1
" IndentLine
let g:indentLine_enabled = 1
let g:indentLine_concealcursor = 0
let g:indentLine_char = '┆'
let g:indentLine_faster = 1
endif
"" Disable the blinking cursor.
set gcr+=a:blinkon0
set scrolloff=3
"" Status bar
set laststatus=2
"" Use modeline overrides
set modeline
set modelines=10
set title
set titleold="Terminal"
set titlestring=%F
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
if exists("*fugitive#statusline")
set statusline+=%{fugitive#statusline()}
endif
"*****************************************************************************
"" XML
"*****************************************************************************
function! DoFormatXML()
:%s/></>\r</g
:0
=:$
endfunction
com! FormatXML call DoFormatXML()
"*****************************************************************************
"" YAML
"*****************************************************************************
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
set foldlevelstart=20
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'
" let g:ale_lint_on_text_changed = 'never'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment