dotfiles/nvim/init.vim

577 lines
21 KiB
VimL

" Specify a directory for plugins (for Neovim: ~/.local/share/nvim/plugged)
call plug#begin('~/.config/nvim/plugged')
" ----------------------------- Plugins --------------------------------------
" Automatically match structures as you type
Plug 'tpope/vim-endwise'
" Tab completion
Plug 'ervandew/supertab'
" EasyMotion - Allows <leader><leader>(b|e) to jump to (b)eginning or (end)
" of words.
Plug 'easymotion/vim-easymotion'
" Fuzzy search
Plug 'Yggdroot/LeaderF', { 'do': './install.sh' }
" Remove extraneous whitespace when edit mode is exited
Plug 'thirtythreeforty/lessspace.vim'
" Status bar mods
Plug 'vim-airline/vim-airline'
" Manage Project sessions
Plug 'thaerkh/vim-workspace'
" Commenter
Plug 'scrooloose/nerdcommenter'
" Theme
Plug 'sickill/vim-monokai'
" Autoload and read from dish if file changes
Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'wellle/tmux-complete.vim'
" For LaTeX support
Plug 'lervag/vimtex'
" For git support
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
Plug 'junegunn/gv.vim'
Plug 'rhysd/git-messenger.vim'
Plug 'idanarye/vim-merginal'
Plug 'christoomey/vim-conflicted'
Plug 'rbong/vim-flog'
" For tmux yank
Plug 'vim-utils/vim-husk'
" Tags
Plug 'sk1418/QFGrep'
Plug 'steffanc/cscopemaps.vim', { 'for': 'c' }
Plug 'deoplete-plugins/deoplete-tag'
" GDB
Plug 'sakhnik/nvim-gdb', { 'do': ':UpdateRemotePlugins' }
" Lisp
Plug 'guns/vim-sexp', { 'for': [ 'scheme', 'lisp', 'clojure' ] }
Plug 'tpope/vim-sexp-mappings-for-regular-people', { 'for': [ 'scheme', 'lisp', 'clojure' ] }
Plug 'junegunn/rainbow_parentheses.vim', { 'for': [ 'scheme', 'lisp', 'clojure' ] }
Plug 'Olical/vim-scheme', { 'for': 'scheme', 'on': 'SchemeConnect' }
" Haskell
Plug 'ekmett/haskell-vim', { 'for': [ 'haskell', 'cabal' ] }
Plug 'neomake/neomake'
Plug 'ndmitchell/ghcid', { 'rtp': 'plugins/nvim' }
Plug 'Twinside/vim-hoogle', { 'for': 'haskell' }
Plug 'hspec/hspec.vim'
Plug 'zenzike/vim-haskell-unicode', { 'for': 'haskell' }
" For Nix
Plug 'LnL7/vim-nix', { 'for': 'nix' }
" For autocompletion
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
" For Python
Plug 'zchee/deoplete-jedi', { 'for': 'python' }
Plug 'numirias/semshi', { 'for': 'python', 'do': ':UpdateRemotePlugins' }
" Autocomplete for Rust
Plug 'sebastianmarkow/deoplete-rust', { 'for': 'rust' }
Plug 'cespare/vim-toml', { 'for': 'rust' }
Plug 'rust-lang/rust.vim', { 'for': 'rust' }
Plug 'mhinz/vim-crates'
" Erlang Support
Plug 'vim-erlang/vim-erlang-tags', { 'for': 'erlang' }
Plug 'vim-erlang/vim-erlang-runtime', { 'for': 'erlang' }
Plug 'vim-erlang/vim-erlang-omnicomplete', { 'for': 'erlang' }
Plug 'vim-erlang/vim-erlang-compiler', { 'for': 'erlang' }
" Miscellaneous
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-sleuth'
Plug 'tpope/vim-vinegar'
Plug 'editorconfig/editorconfig-vim'
Plug 'unblevable/quick-scope'
Plug 'igankevich/mesonic'
Plug 'rhysd/vim-clang-format', { 'for': [ 'c', 'cpp'] }
Plug 'stefandtw/quickfix-reflector.vim'
Plug 'yuttie/comfortable-motion.vim'
Plug 'lifecrisis/vim-difforig'
Plug 'dag/vim-fish'
Plug 'pbrisbin/vim-syntax-shakespeare'
Plug 'lifepillar/pgsql.vim'
Plug 'purescript-contrib/purescript-vim'
Plug 'mbbill/undotree'
Plug 'milkypostman/vim-togglelist'
Plug 'jpalardy/vim-slime'
Plug 'liuchengxu/vim-which-key'
" Initialize plugin system
call plug#end()
" ----------------------------- Settings -------------------------------------
" Set up leaders
let mapleader="\<SPACE>"
set colorcolumn=80 " Highlight 80th column
set laststatus=2 " Always show status bar
set updatetime=500 " Let plugins show effects after 500ms
set mouse-=a " Disable mouse click to go to position
set encoding=utf-8
set exrc " Allow loading local .nvimrc files
set secure " Disallow use of autocmd, shell and write in local rc
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ruler " Show the line and column numbers of the cursor.
set number " Show the line numbers on the left side.
set formatoptions+=o " Continue comment marker in new lines.
set formatoptions+=j " Delete comment character when joining commented lines
set textwidth=80 " Hard-wrap long lines as you type them.
set softtabstop=4 " Finetunes the amount of white space to be added.
set tabstop=4 " Render TABs using this many spaces.
set shiftwidth=4 " Indentation amount for < and > commands.
set smarttab " Indent with tabs, align with spaces.
set expandtab " When on, uses space instead of tabs.
set autoindent " Copy indent from current line when starting a new line
set noerrorbells " No beeps.
set modeline " Enable modeline.
set linespace=0 " Set line-spacing to minimum.
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
set noshowmode " Because of neovim's cursor shape
set splitbelow " Horizontal split below current.
set splitright " Vertical split to right of current.
set nobackup " no backup files
set nowritebackup " only in case you don't want a backup file while editing
set noswapfile " no swap files
set foldmethod=syntax " Create folds based on files syntax
set nofoldenable " Open folds by default
" Wild menu
set wildmenu
set wildmode=list:longest,full
set wildoptions=pum
set pumblend=30
set wildignore+=.hg,.git,.svn " Version control
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o " compiled object files
set wildignore+=*.sw? " Vim swap files
set wildignore+=*.luac " Lua byte code
set wildignore+=*.pyc " Python byte code
set wildignore+=*.orig " Merge resolution files
if !&scrolloff
set scrolloff=3 " Show next 3 lines while scrolling.
endif
if !&sidescrolloff
set sidescrolloff=5 " Show next 5 columns while side-scrolling.
endif
set nostartofline " Do not jump to first character with page commands.
set ignorecase " Make searching case insensitive
set smartcase " ... unless the query has capital letters.
set gdefault " Use 'g' flag by default with :s/foo/bar/.
set magic " Use 'magic' patterns (extended regular expressions).
set autoread " Autoload file if it changes on disk
set termguicolors " Enable colors for terminal
set fileformat=unix
set clipboard^=unnamed,unnamedplus
set backspace=indent,eol,start
set completeopt+=menu,noselect,preview,noinsert
" Required for vim-workspace
" See https://github.com/thaerkh/vim-workspace/issues/11
set sessionoptions-=blank
" Theme
syntax enable
colorscheme monokai
" --------------------------- Key Bindings -----------------------------------
" Use <C-L> to clear the highlighting of :set hlsearch.
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent> <C-L> :nohlsearch<CR><C-L>
endif
" Remap escape keys to something usable on home row
inoremap jk <Esc>
cnoremap jk <C-C>
inoremap <Esc> <Nop>
cnoremap <Esc> <Nop>
" Use ; for commands.
nnoremap ; :
" Use Q to execute default register.
nnoremap Q <Nop>
" Plug shortcuts
nnoremap <Leader>pg :PlugUpgrade<CR>
nnoremap <Leader>pd :PlugUpdate<CR>
nnoremap <Leader>pc :PlugClean<CR>
" For Fuzzy
nnoremap <Leader>vf :LeaderfFile<CR>
nnoremap <Leader>vb :LeaderfBuffer<CR>
nnoremap <Leader>vL :LeaderfLineAll<CR>
nnoremap <Leader>vl :LeaderfLine<CR>
nnoremap <Leader>vh :LeaderfHistorySearch<CR>
nnoremap <Leader>vc :LeaderfHistoryCmd<CR>
nnoremap <Leader>vt :LeaderfTag<CR>
nnoremap <Leader>vw :LeaderfTagCword<CR>
nnoremap <Leader>vm :LeaderfMru<CR>
nnoremap <Leader>d :exe ':Leaderf! rg -e ' . expand("<cword>")<CR>
" Quick buffer switching
nnoremap <Leader>b :ls<CR>:b<Space>
" Undo tree
nnoremap <Leader>u :UndotreeToggle<CR>
" Save
nnoremap <Leader>w <Esc>:w<CR>
" Search and Replace
nnoremap <Leader>sr :%s//g<Left><Left>
" Manage window splitting
nnoremap <Leader>sh <Esc>:sp<CR>
nnoremap <Leader>sv <Esc>:vsp<CR>
" Quit
nnoremap <Leader>x <Esc>:x<CR>
nnoremap <Leader>q <Esc>:q<CR>
nnoremap <Leader>qa <Esc>:qa<CR>
" Terminal
nnoremap <Leader>te :vsp<CR> :terminal<CR>
nnoremap <Leader>tc :SlimeConfig<CR>
xmap <Leader>ts <Plug>SlimeRegionSend
nmap <Leader>ts <Plug>SlimeParagraphSend
" Tab navigation shortcuts
nnoremap <Leader>tn :bn<CR>
nnoremap <Leader>tp :bp<CR>
" Reload opened vim config file
nnoremap <Leader>vr :so %<CR>
" For git
nnoremap <Leader>gm :GitMessenger<CR>
nnoremap <Leader>gl :Glog<CR>
nnoremap <Leader>gd :Gdiffsplit<CR>
nnoremap <Leader>gs :Gstatus<CR>
nnoremap <Leader>gc :Gcommit --signoff<CR>
nnoremap <Leader>gp :Git! push<CR>
nnoremap <Leader>gu :Git! push -u
nnoremap <Leader>gr :Git! remote -v<CR>
nnoremap <Leader>gb :Merginal<CR>
" For gitgutter
nnoremap <Leader>ghn :GitGutterNextHunk<CR>
nnoremap <Leader>ghp :GitGutterPrevHunk<CR>
nnoremap <Leader>ghs :GitGutterStageHunk<CR>
nnoremap <Leader>ghu :GitGutterUndoHunk<CR>
nnoremap <Leader>ghr :GitGutterPreviewHunk<CR>
nnoremap <Leader>gqf :GitGutterQuickFix<CR>
nnoremap <Leader>ggf :GitGutterFold<CR>
" For Cscope & tags
nnoremap <Leader>ct :NeomakeSh ctags -R .<CR>
nnoremap <Leader>cu :NeomakeSh cscope -bqR<CR>
nnoremap <Leader>cr :cs reset<CR>
" For Neomake
nnoremap <Leader>nm :Neomake<CR>
nnoremap <Leader>nc :NeomakeClean<CR>
nnoremap <Leader>ns :NeomakeSh
nnoremap <Leader>njl :NeomakeListJobs<CR>
nnoremap <Leader>nja :NeomakeCancelJobs<CR>
nnoremap <Leader>njc :NeomakeCancelJob
" For workspace
nnoremap <Leader>sw :ToggleWorkspace<CR>
" Haskell specific
nnoremap <Leader>ht :NeomakeSh stack exec -- fast-tags -R .<CR>
" For ghcid
nnoremap <Leader>hg :Ghcid<CR>
nnoremap <Leader>hk :GhcidKill<CR>
" For Hoogle
nnoremap <Leader>hc :HoogleClose<CR>
nnoremap <Leader>ho :exe ':Hoogle ' . expand('<cword>')<CR>
nnoremap <Leader>hi :exe ':HoogleInfo ' . expand('<cword>')<CR>
" Quickfix & Location list mappings
nnoremap <Leader>fn :cnext<CR>
nnoremap <Leader>fp :cprevious<CR>
nnoremap <Leader>fo :copen<CR>
nnoremap <Leader>fc :cclose<CR>
nnoremap <Leader>ft :call ToggleQuickfixList()<CR>
nnoremap <Leader>ffn :lnext<CR>
nnoremap <Leader>ffp :lprevious<CR>
nnoremap <Leader>ffo :lopen<CR>
nnoremap <Leader>ffc :lclose<CR>
nnoremap <Leader>fft :call ToggleLocationList()<CR>
" Key Bindings to help with terminal mode
:tnoremap jk <C-\><C-n>
" Key bindings to move between window splits
nnoremap gh <C-w>h
nnoremap gj <C-w>j
nnoremap gk <C-w>k
nnoremap gl <C-w>l
" Disable Arrow Keys
inoremap <Up> <NOP>
inoremap <Down> <NOP>
inoremap <Left> <NOP>
inoremap <Right> <NOP>
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
nnoremap <silent> <Leader>ss :call Cscope("s", expand('<cword>'))<CR>
nnoremap <silent> <Leader>sg :call Cscope("g", expand('<cword>'))<CR>
nnoremap <silent> <Leader>sd :call Cscope("d", expand('<cword>'))<CR>
nnoremap <silent> <Leader>sc :call Cscope("c", expand('<cword>'))<CR>
nnoremap <silent> <Leader>st :call Cscope("t", expand('<cword>'))<CR>
nnoremap <silent> <Leader>se :call Cscope("e", expand('<cword>'))<CR>
nnoremap <silent> <Leader>sf :call Cscope("f", expand('<cword>'))<CR>
nnoremap <silent> <Leader>si :call Cscope("i", expand('<cword>'))<CR>
nnoremap <silent> <Leader>sa :call Cscope("a", expand('<cword>'))<CR>
nnoremap <silent> <Leader><Leader>ss :call CscopeQuery("s")<CR>
nnoremap <silent> <Leader><Leader>sg :call CscopeQuery("g")<CR>
nnoremap <silent> <Leader><Leader>sd :call CscopeQuery("d")<CR>
nnoremap <silent> <Leader><Leader>sc :call CscopeQuery("c")<CR>
nnoremap <silent> <Leader><Leader>st :call CscopeQuery("t")<CR>
nnoremap <silent> <Leader><Leader>se :call CscopeQuery("e")<CR>
nnoremap <silent> <Leader><Leader>sf :call CscopeQuery("f")<CR>
nnoremap <silent> <Leader><Leader>si :call CscopeQuery("i")<CR>
nnoremap <silent> <Leader><Leader>sa :call CscopeQuery("a")<CR>
nnoremap <silent> <Leader> :<C-U>WhichKey '<Space>'<CR>
" --------------------------- Autocmd groups ---------------------------------
augroup deopleteMaps
au!
" For deoplete Rust
au FileType rust nmap <buffer> <Leader>rd <plug>DeopleteRustGoToDefinitionDefault
au FileType rust nmap <buffer> <Leader>rc <plug>DeopleteRustShowDocumentation
au FileType rust nmap <buffer> <Leader>rv <plug>DeopleteRustGoToDefinitionVSplit
au FileType rust nmap <buffer> <Leader>rh <plug>DeopleteRustGoToDefinitionSplit
au FileType rust nmap <buffer> <Leader>rt <plug>DeopleteRustGoToDefinitionTab
augroup END
augroup rainbow_lisp
autocmd!
autocmd FileType lisp,clojure,scheme RainbowParentheses
augroup END
" Starts the REPL.
autocmd FileType scheme nnoremap <buffer> <Leader>rc :SchemeConnect<cr>
" Evaluates the outer most / top level form and jumps the cursor back to where it was.
autocmd FileType scheme nnoremap <buffer> <Leader>re :normal mscpaF<cr>`s
" Evaluates the entire file.
autocmd FileType scheme nnoremap <buffer> <Leader>rf :normal msggcpG<cr>`s
" Toggles search highlighting off/on according to current mode. Source: http://blog.sanctum.geek.nz/vim-search-highlighting/
augroup ToggleSearchHighlighting
autocmd!
autocmd InsertEnter * setlocal nohlsearch
autocmd InsertLeave * setlocal hlsearch
augroup END
" Close QF window if it is last window
augroup QFClose
au!
au WinEnter * if winnr('$') == 1 && &buftype == "quickfix"|q|endif
augroup END
" Taken from http://seenaburns.com/vim-setup-for-rust/
" Neomake
" Gross hack to stop Neomake running when exitting because it creates a zombie cargo check process
" which holds the lock and never exits. But then, if you only have QuitPre, closing one pane will
" disable neomake, so BufEnter reenables when you enter another buffer.
let s:quitting = 0
au QuitPre *.rs let s:quitting = 1
au BufEnter *.rs let s:quitting = 0
au BufWritePost *.rs if ! s:quitting | Neomake | else | echom "Neomake disabled"| endif
augroup Terminal
au!
au TermOpen * setlocal statusline=%{b:terminal_job_id}
augroup END
" Default indentations
autocmd BufRead,BufNewFile */gst-*/*.[ch] set et sw=2
autocmd BufRead,BufNewFile */gstreamer-*/*.[ch] set et sw=2
autocmd BufRead,BufNewFile */pulseaudio/*.[ch] set et sw=4 tw=128
" Configure expanding of tabs for various file types
au BufRead,BufNewFile *.c set noexpandtab
au BufRead,BufNewFile *.h set noexpandtab
au BufRead,BufNewFile Makefile* set noexpandtab
au BufNewFile,BufRead *.vim setlocal noet ts=4 sw=4 sts=4
au BufNewFile,BufRead *.txt setlocal noet ts=4 sw=4
" Lua settings
autocmd BufNewFile,BufRead *.lua setlocal noet ts=4 sw=4 sts=4
" Python indent
autocmd BufNewFile,BufRead *.py setlocal tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80 smarttab expandtab
" Shell/config/systemd settings
autocmd FileType fstab,systemd set noexpandtab
autocmd FileType gitconfig,sh,toml set noexpandtab
" Spell check for git commits
autocmd FileType gitcommit setlocal spell
" Spell Checking
autocmd BufRead,BufNewFile *.md,*.txt setlocal spell spelllang=en_uk
" Automatically resize the window
autocmd VimResized * wincmd =
" --------------------------- Plugin settings --------------------------------
let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
let g:haskell_classic_highlighting = 0
let g:haskell_indent_if = 3
let g:haskell_indent_case = 2
let g:haskell_indent_let = 4
let g:haskell_indent_where = 6
let g:haskell_indent_before_where = 2
let g:haskell_indent_after_bare_where = 2
let g:haskell_indent_do = 3
let g:haskell_indent_in = 1
let g:haskell_indent_guard = 2
let g:haskell_indent_case_alternative = 1
let g:cabal_indent_section = 2
let g:ghcid_command = 'stack exec -- ghcid'
let g:hoogle_search_bin = 'stack exec -- hoogle'
let g:hoogle_search_count = 30
" Use deoplete
let g:deoplete#enable_at_startup = 1
" Disable autocomplete by default
" let b:deoplete_disable_auto_complete = 1
" let g:deoplete_disable_auto_complete = 1
" Let sources be empty by default
let g:deoplete#sources = {}
" Disable the candidates in Comment/String syntaxes.
call deoplete#custom#source('_',
\ 'disabled_syntaxes', ['Comment', 'String'])
call deoplete#custom#option('sources', {
\ '_' : ['buffer', 'tag'],
\ 'rust': ['racer'],
\})
let g:deoplete#sources#rust#disable_keymap = 1
let g:deoplete#sources#rust#racer_binary=expand('$HOME/.cargo/bin/racer')
let g:deoplete#sources#rust#rust_source_path=expand('$HOME/GitSources/rust/src')
let g:rustfmt_autosave = 1
" Required by Semshi
let g:deoplete#auto_complete_delay = 100
" Use airline
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline#extensions#tabline#right_sep = ' '
let g:airline#extensions#tabline#right_alt_sep = '|'
let g:airline#extensions#tabline#formatter = 'default'
let g:airline_left_sep = ' '
let g:airline_left_alt_sep = '|'
let g:airline_right_sep = ' '
let g:airline_right_alt_sep = '|'
let g:airline#extensions#tabline#buffer_nr_show = 1
" Let vim-gitgutter do its thing on large files
let g:gitgutter_max_signs=1000
let g:gitgutter_map_keys = 0
let g:gitgutter_highlight_linenrs = 1
let g:gitgutter_preview_win_floating = 1
let g:gitgutter_use_location_list = 1
let g:gitgutter_sign_added = '+a'
let g:gitgutter_sign_modified = '+m'
let g:gitgutter_sign_removed = '-r'
let g:gitgutter_sign_removed_first_line = '^^'
let g:gitgutter_sign_modified_removed = 'mr'
" Neomake
" compile when I open a file, change text, leave insert mode, etc ...
call neomake#configure#automake({
\ 'TextChanged': {},
\ 'InsertLeave': {},
\ 'BufWritePost': {},
\ })
" When compilation is done, open the Location list or quickfix list
" Value of 2 preserves cursor position
let g:neomake_open_list = 2
let g:neomake_warning_sign = {'text': '?'}
" Automatically detect style file and apply style to formatting
let g:clang_format#detect_style_file = 1
" Additional trigger not required with deoplete
let g:tmuxcomplete#trigger = ''
" Required for vimtex
let g:vimtex_compiler_progname = 'nvr'
" Fix deoplete's tab behaviour
let g:SuperTabDefaultCompletionType = "<c-n>"
" For workspace
let g:workspace_session_directory = $HOME . '/.vim/session/'
let g:workspace_undodir = $HOME . '/.vim/undodir'
let g:workspace_autosave = 0
let g:workspace_autosave_ignore = ['gitcommit', 'qf', 'tagbar']
let g:workspace_session_disable_on_args = 1
" For comfortable motion
let g:comfortable_motion_scroll_down_key = "j"
let g:comfortable_motion_scroll_up_key = "k"
let g:toggle_list_no_mappings = 1
" Slime
let g:slime_target = "neovim"
let g:slime_no_mappings = 1
let g:slime_python_ipython = 1
let g:slime_dont_ask_default = 1
let g:slime_preserve_curpos = 0
" For LeaderF
let g:Lf_WindowPosition = 'popup'
let g:Lf_PreviewInPopup = 1
let g:Lf_CommandMap = {'<C-K>': ['<Up>'], '<C-J>': ['<Down>']}
let g:nvimgdb_config_override = {
\ 'key_next': 'n',
\ 'key_step': 's',
\ 'key_finish': 'f',
\ 'key_continue': 'c',
\ 'key_until': 'u',
\ 'key_breakpoint': 'b',
\ 'set_tkeymaps': "NvimGdbNoTKeymaps",
\ }
let g:mapleader = "\<Space>"
let g:maplocalleader = ','
let g:which_key_use_floating_win = 1
" ----------------------------- Functions ------------------------------------
" For CScope and Quickfix
" https://medium.com/@lakshmankumar12/quickfix-and-location-list-in-vim-ca0292ac894d
" https://medium.com/@lakshmankumar12/vim-and-cscope-5f4558c8a8b8
function! Cscope(oper, currword)
execute "normal mZ"
execute "set csqf=" . a:oper . "-"
execute "lcs find " a:oper . " " . a:currword
execute "lopen"
execute "wincmd p"
execute "normal `Z"
execute "set csqf="
endfunction
function! CscopeQuery(option)
call inputsave()
if a:option == "s"
let query = input('C Symbol: ')
elseif a:option == "g"
let query = input('Definition: ')
elseif a:option == "d"
let query = input('Functions called by: ')
elseif a:option == "c"
let query = input('Functions calling: ')
elseif a:option == "t"
let query = input('Text: ')
elseif a:option == "e"
let query = input('Egrep: ')
elseif a:option == "f"
let query = input('File: ')
elseif a:option == "i"
let query = input('Files #including: ')
elseif a:option == "a"
let query = input('Assignments to: ')
else
echo "Invalid option!"
return
endif
call inputrestore()
if query != ""
call Cscope(a:option, query)
else
echom "Cancelled Search!"
endif
endfunction
function! NvimGdbNoTKeymaps()
tnoremap <silent> <buffer> <esc> <c-\><c-n>
endfunction