Commit 4ec9bbfb authored by Ashwin Vishnu's avatar Ashwin Vishnu
Browse files

Vim and xonsh mostly

parent bd51ec71
......@@ -21,7 +21,7 @@ trim_trailing_whitespace = false
charset = utf-8
# 4 space indentation
[*.{py,tex}]
[*.{py,tex,xsh}]
indent_style = space
indent_size = 4
......
......@@ -40,20 +40,6 @@ execute('source ~/.config/vimrc/pure.vim')
"{{{ Surround
let g:surround_insert_tail = "<++>"
""Markdown: inline-link maker
"surround with [], find ], append (
au FileType markdown,pandoc nmap <S-CR> ysiW]f]a()<ESC>i
""Markdown: link maker
"yank inner word, surround with [], find ], append [, paste word,
au FileType markdown,pandoc nmap <CR> yiWysiW]f]a[<ESC>pGo<ESC>i[<ESC>p<ESC>$a:<SPACE>
""rST: inline-link maker
"surround with ``, find `, append __, move left by 2 characters, insert <>
au FileType rst nmap <S-CR> ysiW`f`a__<ESC>2hi<SPACE><lt>><ESC>i
""rST: link maker
"yank inner word, go to end of word, append _, mark l, end of document, add a
"new line, insert .. _, paste, append:
au FileType rst nmap <CR> yiWEa_<ESC>mlGo<ESC>i..<SPACE>_<ESC>pa:
"}}}
"{{{ FileType and Buffer settings
......@@ -142,6 +128,15 @@ let g:neoformat_tex_latexindent = {
\ 'args': ['-l', '-g /dev/null'],
\ 'stdin': 1,
\ }
let g:neoformat_snakemake_snakefmt = {
\ 'exe': 'snakefmt',
\ 'args': ['-l '.g:black_linelength, '-'],
\ 'stdin': 1,
\ }
let g:neoformat_enabled_snakemake = ['snakefmt']
"}}}
"{{{ ALE settings
......@@ -487,6 +482,10 @@ au FileType rust setlocal makeprg=cargo\ run
let test#strategy = "asyncrun_background"
"}}}
" {{{xonsh
au Filetype xonsh setlocal comments=b:#,fb:- commentstring=#\ %s
" }}}
"{{{ Custom commands: AVFocusMode
function! s:focus_mode()
LspDisable
......@@ -497,6 +496,8 @@ endfunction
command! AVFocusMode :call s:focus_mode()
"}}}
if match(s:my_plug_config, '.*packrc.*') == 0
call PackPostVimrc()
endif
......@@ -20,7 +20,7 @@ Plug 'morhetz/gruvbox'
" Material themes
" Plug 'chriskempson/base16-vim'
" Plug 'kaicataldo/material.vim'
if isdirectory('~/src/projects/material.vim')
if isdirectory(expand('~/src/projects/material.vim'))
Plug '~/src/projects/material.vim'
else
Plug 'ashwinvis/material.vim', {'branch': 'dev'}
......@@ -100,8 +100,8 @@ Plug 'goerz/jupytext.vim'
Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'}
"IDE-like experience
Plug 'z-huabao/vim-submode'
Plug 'z-huabao/vim-slime-ipython'
Plug 'z-huabao/vim-submode', {'for': ['python', 'snakemake', 'xonsh']}
Plug 'z-huabao/vim-slime-ipython', {'for': ['python', 'snakemake', 'xonsh']}
"}}}
"{{{ Distraction free
......@@ -124,11 +124,16 @@ Plug 'dhruvasagar/vim-table-mode', {'for': ['markdown.pandoc', 'markdown', 'rst'
"Plug 'suan/vim-instant-markdown', {'for': 'markdown'}
"Plug 'ashwinvis/vim-instant-markdown', {'for': 'markdown'}
"Plug 'ashwinvis/vim-instant-markdown', {'for': 'markdown', 'dir': '~/src/vim-markdown/vim-instant-markdown'}
if isdirectory('~/src/projects/vim-instant-markdown')
if isdirectory(expand('~/src/projects/vim-instant-markdown'))
Plug '~/src/projects/vim-instant-markdown', {'for': ['markdown', 'markdown.pandoc']}
else
Plug 'suan/vim-instant-markdown', {'for': ['markdown', 'markdown.pandoc']}
endif
if isdirectory(expand('~/src/projects/boring-writing'))
Plug '~/src/projects/boring-writing'
else
Plug 'https://codeberg.org/ashwinvis/boring-writing'
endif
"Plug 'iamcco/markdown-preview.nvim', {'for': 'markdown', 'do': 'cd app & yarn install'}
"Plug 'JamshedVesuna/vim-markdown-preview', {'for': 'markdown'}
" Plug 'vim-pandoc/vim-pandoc', {'on': 'Pandoc'}
......@@ -163,7 +168,6 @@ Plug 'tpope/vim-fugitive' ", {'tag': 'v2.5'}
" Plug 'ludovicchabant/vim-lawrencium'
"}}}
"{{{ Async plugins
""""""""""""""
if g:has_nvim || g:has_vim8
......@@ -186,7 +190,8 @@ Plug 'mattn/vim-lsp-settings'
if g:has_python
"Plug 'sjl/gundo.vim'
"Undo
Plug 'simnalamburt/vim-mundo'
"Plug 'simnalamburt/vim-mundo'
Plug 'mbbill/undotree'
" Plug 'davidhalter/jedi-vim', {'for': 'python', 'on': 'Pyimport'}
" Plug 'deoplete-plugins/deoplete-jedi', {'for': 'python'}
......@@ -213,4 +218,8 @@ if g:has_python
endif
" }}}
"{{{Vim unittests
Plug 'junegunn/vader.vim'
"}}}
call plug#end()
......@@ -87,12 +87,20 @@ syntax on
set hidden " For language server?
set nomodeline " Disallow exploit, use ciaranm/securemodelines if needed
set conceallevel=1
set backup "backup files to backupdir
if g:has_nvim
set shada+=n~/.cache/nvim/viminfo
set backupdir-=. " Do not save backup files in current directory
else
set viminfo+=n~/.cache/vim/viminfo
endif
"ensure backupdir
let s:backupdir=&backupdir
if !isdirectory(s:backupdir)
silent exec "!mkdir -p ".s:backupdir
endif
if getcwd() =~# '^\(/home/avmo/src/snek5000\)'
set secure exrc "execute project / directory specific .vimrc
endif
......@@ -128,13 +136,6 @@ nnoremap <leader>syn :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name")
"Avoid fzf.vim from hijacking with the windows command
command! W w
"Change dir to current file
command! CDC lcd %:p:h
nnoremap <leader>cd :CDC<CR>:pwd<CR>
"Vertical split find
command! -nargs=1 -complete=file_in_path V vert sfind <args>
command! -nargs=1 -complete=file_in_path F find <args>
"Jump to end of the line
nnoremap <C-j> f<Space>
......@@ -142,10 +143,6 @@ nnoremap <C-j> f<Space>
"Clipboard
"Now all regular copy operations will copy to the system clipboard too :)
set clipboard=unnamedplus
"copy in visual mode
vnoremap <C-c> "+y
"paste in insert mode
inoremap <C-v> <C-o>"+gp
"Buffer switching with ls
"FZF reassign Not working :(
......@@ -243,7 +240,6 @@ nnoremap <leader>ms :call MakeSession()<CR>
nnoremap <leader>ds :call DelSession()<CR>
""}}}
"{{{ NERD Tree / Netrw
"""""""""""""""""""
" map <C-n> :NERDTreeToggle<CR>
......@@ -341,29 +337,3 @@ au FileType json,c,cpp,fortran,xml,html,xhtml,perl normal zR
nnoremap <space> za
"}}}
"{{{ Select (visual mode) and search / replace
""""""""""""""""""""""""""""""""""""""""""
if has('python3')
python3 << endpython3
import re
import vim
def py_regex_escape(string=None):
h = string if string else vim.eval('@h')
h = re.escape(h).replace("'", "''")
if string:
print(h)
else:
vim.command("let @h='{}'".format(h))
endpython3
command! -nargs=? RegexEscape :py3 py_regex_escape(<f-args>)
" http://stackoverflow.com/questions/676600/#676619
" Below h is used as a register to yank into
" Also search with \v prefix for searching with no magic and
" if needed \V prefix with very magic. See `:help magic`
vnoremap <C-f> "hy:RegexEscape<CR>/\v<C-r>h
vnoremap <C-r> "hy:RegexEscape<CR>:%s/\v<C-r>h//gc<left><left><left>
endif
"}}}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment