nvim
This commit is contained in:
parent
ca3b18c310
commit
b24671d186
|
@ -0,0 +1,5 @@
|
|||
let g:netrw_dirhistmax =10
|
||||
let g:netrw_dirhist_cnt =3
|
||||
let g:netrw_dirhist_1='/home/odrling/.config/i3blocks/battery'
|
||||
let g:netrw_dirhist_2='/home/odrling/.local'
|
||||
let g:netrw_dirhist_3='/home/odrling/.zsh'
|
|
@ -0,0 +1 @@
|
|||
../vim-pathogen/autoload/pathogen.vim
|
|
@ -0,0 +1,468 @@
|
|||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Maintainer:
|
||||
" Amir Salihefendic — @amix3k
|
||||
"
|
||||
" Awesome_version:
|
||||
" Get this config, nice color schemes and lots of plugins!
|
||||
"
|
||||
" Install the awesome version from:
|
||||
"
|
||||
" https://github.com/amix/vimrc
|
||||
"
|
||||
" Sections:
|
||||
" -> General
|
||||
" -> VIM user interface
|
||||
" -> Colors and Fonts
|
||||
" -> Files and backups
|
||||
" -> Text, tab and indent related
|
||||
" -> Visual mode related
|
||||
" -> Moving around, tabs and buffers
|
||||
" -> Status line
|
||||
" -> Editing mappings
|
||||
" -> vimgrep searching and cope displaying
|
||||
" -> Spell checking
|
||||
" -> Misc
|
||||
" -> Helper functions
|
||||
"
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => General
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Sets how many lines of history VIM has to remember
|
||||
set history=500
|
||||
set number relativenumber
|
||||
|
||||
" Enable filetype plugins
|
||||
filetype plugin on
|
||||
filetype indent on
|
||||
|
||||
" fuzzy search
|
||||
set path+=**
|
||||
set wildmenu
|
||||
|
||||
" Set to auto read when a file is changed from the outside
|
||||
set autoread
|
||||
|
||||
" With a map leader it's possible to do extra key combinations
|
||||
" like <leader>w saves the current file
|
||||
let mapleader = ","
|
||||
|
||||
" Fast saving
|
||||
nmap <leader>w :w!<cr>
|
||||
nmap <leader>j :wn<cr>
|
||||
nmap <leader>k :wN<cr>
|
||||
nmap <leader>b :w<CR>:b<SPACE>
|
||||
|
||||
" Oh well
|
||||
nmap <leader>; A;<esc>
|
||||
|
||||
" :W sudo saves the file
|
||||
" (useful for handling the permission-denied error)
|
||||
command W w !sudo tee % > /dev/null
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => VIM user interface
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Set 5 lines to the cursor - when moving vertically using j/k
|
||||
set so=5
|
||||
|
||||
" Avoid garbled characters in Chinese language windows OS
|
||||
let $LANG='en'
|
||||
set langmenu=en
|
||||
source $VIMRUNTIME/delmenu.vim
|
||||
source $VIMRUNTIME/menu.vim
|
||||
|
||||
" Turn on the Wild menu
|
||||
set wildmenu
|
||||
|
||||
" Ignore compiled files
|
||||
set wildignore=*.o,*~,*.pyc
|
||||
if has("win16") || has("win32")
|
||||
set wildignore+=.git\*,.hg\*,.svn\*
|
||||
else
|
||||
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
|
||||
endif
|
||||
|
||||
"Always show current position
|
||||
set ruler
|
||||
|
||||
" Height of the command bar
|
||||
set cmdheight=1
|
||||
|
||||
" A buffer becomes hidden when it is abandoned
|
||||
set hid
|
||||
|
||||
" Configure backspace so it acts as it should act
|
||||
set backspace=eol,start,indent
|
||||
set whichwrap+=<,>,h,l
|
||||
|
||||
" Ignore case when searching
|
||||
set ignorecase
|
||||
|
||||
" When searching try to be smart about cases
|
||||
set smartcase
|
||||
|
||||
" Highlight search results
|
||||
set hlsearch
|
||||
|
||||
" Makes search act like search in modern browsers
|
||||
set incsearch
|
||||
|
||||
" Don't redraw while executing macros (good performance config)
|
||||
set lazyredraw
|
||||
|
||||
" For regular expressions turn magic on
|
||||
set magic
|
||||
|
||||
" Show matching brackets when text indicator is over them
|
||||
set showmatch
|
||||
" How many tenths of a second to blink when matching brackets
|
||||
set mat=2
|
||||
|
||||
" No annoying sound on errors
|
||||
set noerrorbells
|
||||
set novisualbell
|
||||
set t_vb=
|
||||
set tm=500
|
||||
|
||||
" Properly disable sound on errors on MacVim
|
||||
if has("gui_macvim")
|
||||
autocmd GUIEnter * set vb t_vb=
|
||||
endif
|
||||
|
||||
|
||||
" Add a bit extra margin to the left
|
||||
set foldcolumn=1
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Colors and Fonts
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Enable syntax highlighting
|
||||
syntax enable
|
||||
|
||||
" Enable 256 colors palette in Gnome Terminal
|
||||
" if $COLORTERM == 'gnome-terminal'
|
||||
" set t_Co=256
|
||||
" endif
|
||||
|
||||
try
|
||||
colorscheme desert
|
||||
catch
|
||||
endtry
|
||||
|
||||
let g:airline_theme='minimalist'
|
||||
|
||||
set background=dark
|
||||
|
||||
" Set extra options when running in GUI mode
|
||||
if has("gui_running")
|
||||
set guioptions-=T
|
||||
set guioptions-=e
|
||||
set t_Co=256
|
||||
set guitablabel=%M\ %t
|
||||
endif
|
||||
|
||||
" Set utf8 as standard encoding and en_US as the standard language
|
||||
set encoding=utf8
|
||||
|
||||
" Use Unix as the standard file type
|
||||
set ffs=unix,dos,mac
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Files, backups and undo
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Turn backup off, since most stuff is in SVN, git et.c anyway...
|
||||
set nobackup
|
||||
set nowb
|
||||
set noswapfile
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Text, tab and indent related
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Use spaces instead of tabs
|
||||
set expandtab
|
||||
|
||||
" Be smart when using tabs ;)
|
||||
set smarttab
|
||||
|
||||
" 1 tab == 4 spaces
|
||||
set shiftwidth=4
|
||||
set tabstop=4
|
||||
|
||||
" Linebreak on 500 characters
|
||||
set lbr
|
||||
set tw=500
|
||||
|
||||
set ai "Auto indent
|
||||
set si "Smart indent
|
||||
set wrap "Wrap lines
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""
|
||||
" => Visual mode related
|
||||
""""""""""""""""""""""""""""""
|
||||
" Visual mode pressing * or # searches for the current selection
|
||||
" Super useful! From an idea by Michael Naumann
|
||||
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
|
||||
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Moving around, tabs, windows and buffers
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Map <Space> to / (search) and Ctrl-<Space> to ? (backwards search)
|
||||
"map <space> /
|
||||
"map <c-space> ?
|
||||
|
||||
" Disable highlight when <leader><cr> is pressed
|
||||
map <silent> <leader><cr> :noh<cr>
|
||||
|
||||
" Smart way to move between windows
|
||||
map <C-j> <C-W>j
|
||||
map <C-k> <C-W>k
|
||||
map <C-h> <C-W>h
|
||||
map <C-l> <C-W>l
|
||||
|
||||
" Close the current buffer
|
||||
map <leader>bd :Bclose<cr>:tabclose<cr>gT
|
||||
|
||||
" Close all the buffers
|
||||
map <leader>ba :bufdo bd<cr>
|
||||
|
||||
map <leader>l :bnext<cr>
|
||||
map <leader>h :bprevious<cr>
|
||||
|
||||
" Useful mappings for managing tabs
|
||||
map <leader>tn :tabnew<cr>
|
||||
map <leader>to :tabonly<cr>
|
||||
map <leader>tc :tabclose<cr>
|
||||
map <leader>tm :tabmove
|
||||
map <leader>t<leader> :tabnext
|
||||
|
||||
" Let 'tl' toggle between this and the last accessed tab
|
||||
let g:lasttab = 1
|
||||
nmap <Leader>tl :exe "tabn ".g:lasttab<CR>
|
||||
au TabLeave * let g:lasttab = tabpagenr()
|
||||
|
||||
|
||||
" Opens a new tab with the current buffer's path
|
||||
" Super useful when editing files in the same directory
|
||||
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
|
||||
|
||||
" Switch CWD to the directory of the open buffer
|
||||
map <leader>cd :cd %:p:h<cr>:pwd<cr>
|
||||
|
||||
" Specify the behavior when switching between buffers
|
||||
try
|
||||
set switchbuf=useopen,usetab,newtab
|
||||
set stal=2
|
||||
catch
|
||||
endtry
|
||||
|
||||
" Return to last edit position when opening files (You want this!)
|
||||
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""
|
||||
" => Status line
|
||||
""""""""""""""""""""""""""""""
|
||||
" Always show the status line
|
||||
set laststatus=2
|
||||
|
||||
" Format the status line
|
||||
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Editing mappings
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Remap VIM 0 to first non-blank character
|
||||
map 0 ^
|
||||
|
||||
" Move a line of text using ALT+[jk] or Command+[jk] on mac
|
||||
nmap <M-j> mz:m+<cr>`z
|
||||
nmap <M-k> mz:m-2<cr>`z
|
||||
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
|
||||
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
|
||||
|
||||
if has("mac") || has("macunix")
|
||||
nmap <D-j> <M-j>
|
||||
nmap <D-k> <M-k>
|
||||
vmap <D-j> <M-j>
|
||||
vmap <D-k> <M-k>
|
||||
endif
|
||||
|
||||
" Delete trailing white space on save, useful for some filetypes ;)
|
||||
fun! CleanExtraSpaces()
|
||||
let save_cursor = getpos(".")
|
||||
let old_query = getreg('/')
|
||||
silent! %s/\s\+$//e
|
||||
call setpos('.', save_cursor)
|
||||
call setreg('/', old_query)
|
||||
endfun
|
||||
|
||||
if has("autocmd")
|
||||
autocmd BufWritePre *.txt,*.c,*.js,*.py,*.java,*.wiki,*.sh,*.coffee,*.adb,*ads :call CleanExtraSpaces()
|
||||
endif
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Spell checking
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Pressing ,ss will toggle and untoggle spell checking
|
||||
map <leader>ss :setlocal spell!<cr>
|
||||
|
||||
" Shortcuts using <leader>
|
||||
map <leader>sn ]s
|
||||
map <leader>sp [s
|
||||
map <leader>sa zg
|
||||
map <leader>s? z=
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Misc
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" git
|
||||
noremap <C-z> :Gw<CR>
|
||||
noremap <C-c> :Gcommit<CR>
|
||||
|
||||
" Remove the Windows ^M - when the encodings gets messed up
|
||||
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
|
||||
|
||||
" turn off highlighting
|
||||
map <leader>h :noh<CR>
|
||||
|
||||
" Quickly open a buffer for scribble
|
||||
map <leader>q :e ~/buffer<cr>
|
||||
|
||||
" Quickly open a markdown buffer for scribble
|
||||
map <leader>x :e ~/buffer.md<cr>
|
||||
|
||||
" Toggle paste mode on and off
|
||||
map <leader>pp :setlocal paste!<cr>
|
||||
|
||||
" Move to the next marker
|
||||
inoremap <C-j> <Esc>/<++><CR>"_c4l
|
||||
inoremap <C-j><C-j> <++>
|
||||
nnoremap <Space> a<++><ESC>
|
||||
|
||||
" copy line to clipboard
|
||||
nnoremap <C-b> "+yy
|
||||
|
||||
|
||||
" file completion
|
||||
inoremap <C-f> <C-x><C-f>
|
||||
|
||||
" tag completion
|
||||
inoremap <C-]> <C-x><C-]>
|
||||
|
||||
" create line above
|
||||
inoremap <S-Enter> <Esc>O
|
||||
|
||||
" adathings
|
||||
autocmd FileType ada ab if<space> if then<CR><++><CR>end if;<CR><++><Esc>3k0ea
|
||||
autocmd FileType ada ab while while loop<CR><++><CR>end loop;<CR><++><Esc>3k0ea
|
||||
autocmd FileType ada ab for for loop<CR><++><CR>end loop;<CR><++><Esc>3k0ea
|
||||
autocmd FileType ada ab proc procedure is<CR>begin<CR><++><CR>end;<CR><++><ESC>4k^ea
|
||||
autocmd FileType ada ab pros procedure;<CR><++><ESC>k^ea
|
||||
autocmd FileType ada ab func function(<++>) return <++><CR>end;<CR><++><ESC>3kea
|
||||
autocmd FileType ada ab funs function(<++>) return <++>;<CR><++><ESC>k^ea
|
||||
autocmd FileType ada ab pack package is<CR><++><CR>end;<CR><++><ESC>3kea
|
||||
autocmd FileType ada ab use use <ESC>0wyf;$pa
|
||||
autocmd FileType ada ab case case is<CR>when others => <++><CR>end case;<ESC>2k^ea
|
||||
autocmd FileType ada ab loop loop<CR>end loop;<ESC>kA
|
||||
|
||||
" pythonthings
|
||||
autocmd FileType python map #! ggi#!/usr/bin/env python3<CR><ESC>:silent exec "!chmod +x %"<CR>
|
||||
autocmd FileType python map ;m oif __name__ == '__main__':<CR>main()<ESC>^
|
||||
autocmd FileType python map <C-i> :w<CR>:silent exec "!isort %"<CR>:e %<CR>
|
||||
|
||||
" javathings
|
||||
autocmd FileType java ab sop System.out.print
|
||||
autocmd FileType java ab sopln System.out.println
|
||||
autocmd FileType java ab main public static void main(String[] args)
|
||||
|
||||
" shellthings
|
||||
autocmd FileType sh map #! ggi#!/bin/sh<CR>
|
||||
autocmd FileType sh inoremap if if ; then<CR><++><CR>fi<CR><++><ESC>3k^ela
|
||||
autocmd FileType sh inoremap for for ; do<CR><++><CR>done<CR><++><ESC>3k^ela
|
||||
autocmd FileType sh inoremap while while ; do<CR><++><CR>done<CR><++><ESC>3k^ela
|
||||
|
||||
" markdown
|
||||
autocmd FileType markdown ab h1 #
|
||||
autocmd FileType markdown ab h2 ##
|
||||
autocmd FileType markdown ab h3 ###
|
||||
autocmd FileType markdown ab h4 ####
|
||||
autocmd FileType markdown ab h5 #####
|
||||
autocmd FileType markdown ab h6 ######
|
||||
|
||||
" html
|
||||
autocmd BufNewFile *.html 0r ~/.templates/html
|
||||
autocmd BufNewFile *.html exe "normal 3jf>l" | startinsert
|
||||
|
||||
" file browsing
|
||||
let g:netrw_banner=0 " disable the banner
|
||||
let g:netrw_liststyle=3 " tree view
|
||||
map <C-o> :FZF<CR>
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Helper functions
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Returns true if paste mode is enabled
|
||||
function! HasPaste()
|
||||
if &paste
|
||||
return 'PASTE MODE '
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Don't close window, when deleting a buffer
|
||||
command! Bclose call <SID>BufcloseCloseIt()
|
||||
function! <SID>BufcloseCloseIt()
|
||||
let l:currentBufNum = bufnr("%")
|
||||
let l:alternateBufNum = bufnr("#")
|
||||
|
||||
if buflisted(l:alternateBufNum)
|
||||
buffer #
|
||||
else
|
||||
bnext
|
||||
endif
|
||||
|
||||
if bufnr("%") == l:currentBufNum
|
||||
new
|
||||
endif
|
||||
|
||||
if buflisted(l:currentBufNum)
|
||||
execute("bdelete! ".l:currentBufNum)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! CmdLine(str)
|
||||
call feedkeys(":" . a:str)
|
||||
endfunction
|
||||
|
||||
function! VisualSelection(direction, extra_filter) range
|
||||
let l:saved_reg = @"
|
||||
execute "normal! vgvy"
|
||||
|
||||
let l:pattern = escape(@", "\\/.*'$^~[]")
|
||||
let l:pattern = substitute(l:pattern, "\n$", "", "")
|
||||
|
||||
if a:direction == 'gv'
|
||||
call CmdLine("Ack '" . l:pattern . "' " )
|
||||
elseif a:direction == 'replace'
|
||||
call CmdLine("%s" . '/'. l:pattern . '/')
|
||||
endif
|
||||
|
||||
let @/ = l:pattern
|
||||
let @" = l:saved_reg
|
||||
endfunction
|
||||
|
||||
execute pathogen#infect()
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
Follow the commit message guidelines at [commit.style](https://commit.style).
|
||||
This is an absolute requirement for my repositories, and doing so proves you
|
||||
actually read the contribution guidelines, which makes for a good first
|
||||
impression.
|
||||
|
||||
Good commit messages imply good commits. Pull requests should typically be a
|
||||
single commit, or for the rare complicated case, a series of atomic commits.
|
||||
If I request a change, use `git commit --amend` or `git rebase --interactive`
|
||||
and force push to your branch.
|
||||
|
||||
For feature requests, don't be shy about proposing it in an issue before
|
||||
drafting a patch. If it's a great idea, I might do it for you. If it's a
|
||||
terrible idea, no patch will change my mind.
|
||||
|
||||
The worst ideas are configuration options. You'll need to provide a great
|
||||
justification in order to persuade me to take on the maintenance and support
|
||||
burden it will inevitably entail. See if you can get away with a custom map
|
||||
or autocommand instead.
|
|
@ -0,0 +1,153 @@
|
|||
# pathogen.vim
|
||||
|
||||
Manage your `'runtimepath'` with ease. In practical terms, pathogen.vim
|
||||
makes it super easy to install plugins and runtime files in their own
|
||||
private directories.
|
||||
|
||||
**For new users, I recommend using Vim's built-in package management
|
||||
instead.** `:help packages`
|
||||
|
||||
## Installation
|
||||
|
||||
Install to `~/.vim/autoload/pathogen.vim`.
|
||||
Or copy and paste the following into your terminal/shell:
|
||||
|
||||
mkdir -p ~/.vim/autoload ~/.vim/bundle && \
|
||||
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
|
||||
|
||||
If you're using Windows, change all occurrences of `~/.vim` to `~\vimfiles`.
|
||||
|
||||
## Runtime Path Manipulation
|
||||
|
||||
Add this to your vimrc:
|
||||
|
||||
execute pathogen#infect()
|
||||
|
||||
If you're brand new to Vim and lacking a vimrc, `vim ~/.vimrc` and paste
|
||||
in the following super-minimal example:
|
||||
|
||||
execute pathogen#infect()
|
||||
syntax on
|
||||
filetype plugin indent on
|
||||
|
||||
Now any plugins you wish to install can be extracted to a subdirectory
|
||||
under `~/.vim/bundle`, and they will be added to the `'runtimepath'`.
|
||||
Observe:
|
||||
|
||||
cd ~/.vim/bundle && \
|
||||
git clone https://github.com/tpope/vim-sensible.git
|
||||
|
||||
Now [sensible.vim](https://github.com/tpope/vim-sensible) is installed.
|
||||
If you really want to get crazy, you could set it up as a submodule in
|
||||
whatever repository you keep your dot files in. I don't like to get
|
||||
crazy.
|
||||
|
||||
If you don't like the directory name `bundle`, you can pass a runtime relative
|
||||
glob as an argument:
|
||||
|
||||
execute pathogen#infect('stuff/{}')
|
||||
|
||||
The `{}` indicates where the expansion should occur.
|
||||
|
||||
You can also pass an absolute path instead. I keep the plugins I maintain under `~/src`, and this is how I add them:
|
||||
|
||||
execute pathogen#infect('bundle/{}', '~/src/vim/bundle/{}')
|
||||
|
||||
Normally to generate documentation, Vim expects you to run `:helptags`
|
||||
on each directory with documentation (e.g., `:helptags ~/.vim/doc`).
|
||||
Provided with pathogen.vim is a `:Helptags` command that does this on
|
||||
every directory in your `'runtimepath'`. If you really want to get
|
||||
crazy, you could even invoke `Helptags` in your vimrc. I don't like to
|
||||
get crazy.
|
||||
|
||||
Finally, pathogen.vim has a rich API that can manipulate `'runtimepath'`
|
||||
and other comma-delimited path options in ways most people will never
|
||||
need to do. If you're one of those edge cases, look at the source.
|
||||
It's well documented.
|
||||
|
||||
## Native Vim Package Management
|
||||
|
||||
Vim 8 includes support for package management in a manner similar to
|
||||
pathogen.vim. If you'd like to transition to this native support,
|
||||
pathogen.vim can help. Calling `pathogen#infect()` on an older version of Vim
|
||||
will supplement the `bundle/{}` default with `pack/{}/start/{}`, effectively
|
||||
backporting a subset of the new native functionality.
|
||||
|
||||
## Runtime File Editing
|
||||
|
||||
`:Vopen`, `:Vedit`, `:Vsplit`, `:Vvsplit`, `:Vtabedit`, `:Vpedit`, and
|
||||
`:Vread` have all moved to [scriptease.vim][].
|
||||
|
||||
[scriptease.vim]: https://github.com/tpope/vim-scriptease
|
||||
|
||||
## FAQ
|
||||
|
||||
> Can I put pathogen.vim in a submodule like all my other plugins?
|
||||
|
||||
Sure, stick it under `~/.vim/bundle`, and prepend the following to your
|
||||
vimrc:
|
||||
|
||||
runtime bundle/vim-pathogen/autoload/pathogen.vim
|
||||
|
||||
Or if your bundles are somewhere other than `~/.vim` (say, `~/src/vim`):
|
||||
|
||||
source ~/src/vim/bundle/vim-pathogen/autoload/pathogen.vim
|
||||
|
||||
> Will you accept these 14 pull requests adding a `.gitignore` for
|
||||
> `tags` so I don't see untracked changes in my dot files repository?
|
||||
|
||||
No, but I'll teach you how to ignore `tags` globally:
|
||||
|
||||
git config --global core.excludesfile '~/.cvsignore'
|
||||
echo tags >> ~/.cvsignore
|
||||
|
||||
While any filename will work, I've chosen to follow the ancient
|
||||
tradition of `.cvsignore` because utilities like rsync use it, too.
|
||||
Clever, huh?
|
||||
|
||||
> What about Vimballs?
|
||||
|
||||
If you really must use one:
|
||||
|
||||
:e name.vba
|
||||
:!mkdir ~/.vim/bundle/name
|
||||
:UseVimball ~/.vim/bundle/name
|
||||
|
||||
> Why don't my plugins load when I use Vim sessions?
|
||||
|
||||
Vim sessions default to capturing all global options, which includes the
|
||||
`'runtimepath'` that pathogen.vim manipulates. This can cause other problems
|
||||
too, so I recommend turning that behavior off:
|
||||
|
||||
set sessionoptions-=options
|
||||
|
||||
## Contributing
|
||||
|
||||
If your [commit message sucks](http://stopwritingramblingcommitmessages.com/),
|
||||
I'm not going to accept your pull request. I've explained very politely
|
||||
dozens of times that
|
||||
[my general guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
|
||||
are absolute rules on my own repositories, so I may lack the energy to
|
||||
explain it to you yet another time. And please, if I ask you to change
|
||||
something, `git commit --amend`.
|
||||
|
||||
Beyond that, don't be shy about asking before patching. What takes you
|
||||
hours might take me minutes simply because I have both domain knowledge
|
||||
and a perverse knowledge of Vim script so vast that many would consider
|
||||
it a symptom of mental illness. On the flip side, some ideas I'll
|
||||
reject no matter how good the implementation is. "Send a patch" is an
|
||||
edge case answer in my book.
|
||||
|
||||
## Self-Promotion
|
||||
|
||||
Like pathogen.vim? Follow the repository on
|
||||
[GitHub](https://github.com/tpope/vim-pathogen) and vote for it on
|
||||
[vim.org](http://www.vim.org/scripts/script.php?script_id=2332). And if
|
||||
you're feeling especially charitable, follow [tpope](http://tpo.pe/) on
|
||||
[Twitter](http://twitter.com/tpope) and
|
||||
[GitHub](https://github.com/tpope).
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) Tim Pope. Distributed under the same terms as Vim itself.
|
||||
See `:help license`.
|
|
@ -0,0 +1,264 @@
|
|||
" pathogen.vim - path option manipulation
|
||||
" Maintainer: Tim Pope <http://tpo.pe/>
|
||||
" Version: 2.4
|
||||
|
||||
" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
|
||||
"
|
||||
" For management of individually installed plugins in ~/.vim/bundle (or
|
||||
" ~\vimfiles\bundle), adding `execute pathogen#infect()` to the top of your
|
||||
" .vimrc is the only other setup necessary.
|
||||
"
|
||||
" The API is documented inline below.
|
||||
|
||||
if exists("g:loaded_pathogen") || &cp
|
||||
finish
|
||||
endif
|
||||
let g:loaded_pathogen = 1
|
||||
|
||||
" Point of entry for basic default usage. Give a relative path to invoke
|
||||
" pathogen#interpose() or an absolute path to invoke pathogen#surround().
|
||||
" Curly braces are expanded with pathogen#expand(): "bundle/{}" finds all
|
||||
" subdirectories inside "bundle" inside all directories in the runtime path.
|
||||
" If no arguments are given, defaults "bundle/{}", and also "pack/{}/start/{}"
|
||||
" on versions of Vim without native package support.
|
||||
function! pathogen#infect(...) abort
|
||||
if a:0
|
||||
let paths = filter(reverse(copy(a:000)), 'type(v:val) == type("")')
|
||||
else
|
||||
let paths = ['bundle/{}', 'pack/{}/start/{}']
|
||||
endif
|
||||
if has('packages')
|
||||
call filter(paths, 'v:val !~# "^pack/[^/]*/start/[^/]*$"')
|
||||
endif
|
||||
let static = '^\%([$~\\/]\|\w:[\\/]\)[^{}*]*$'
|
||||
for path in filter(copy(paths), 'v:val =~# static')
|
||||
call pathogen#surround(path)
|
||||
endfor
|
||||
for path in filter(copy(paths), 'v:val !~# static')
|
||||
if path =~# '^\%([$~\\/]\|\w:[\\/]\)'
|
||||
call pathogen#surround(path)
|
||||
else
|
||||
call pathogen#interpose(path)
|
||||
endif
|
||||
endfor
|
||||
call pathogen#cycle_filetype()
|
||||
if pathogen#is_disabled($MYVIMRC)
|
||||
return 'finish'
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Split a path into a list.
|
||||
function! pathogen#split(path) abort
|
||||
if type(a:path) == type([]) | return a:path | endif
|
||||
if empty(a:path) | return [] | endif
|
||||
let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
|
||||
return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
|
||||
endfunction
|
||||
|
||||
" Convert a list to a path.
|
||||
function! pathogen#join(...) abort
|
||||
if type(a:1) == type(1) && a:1
|
||||
let i = 1
|
||||
let space = ' '
|
||||
else
|
||||
let i = 0
|
||||
let space = ''
|
||||
endif
|
||||
let path = ""
|
||||
while i < a:0
|
||||
if type(a:000[i]) == type([])
|
||||
let list = a:000[i]
|
||||
let j = 0
|
||||
while j < len(list)
|
||||
let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
|
||||
let path .= ',' . escaped
|
||||
let j += 1
|
||||
endwhile
|
||||
else
|
||||
let path .= "," . a:000[i]
|
||||
endif
|
||||
let i += 1
|
||||
endwhile
|
||||
return substitute(path,'^,','','')
|
||||
endfunction
|
||||
|
||||
" Convert a list to a path with escaped spaces for 'path', 'tag', etc.
|
||||
function! pathogen#legacyjoin(...) abort
|
||||
return call('pathogen#join',[1] + a:000)
|
||||
endfunction
|
||||
|
||||
" Turn filetype detection off and back on again if it was already enabled.
|
||||
function! pathogen#cycle_filetype() abort
|
||||
if exists('g:did_load_filetypes')
|
||||
filetype off
|
||||
filetype on
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Check if a bundle is disabled. A bundle is considered disabled if its
|
||||
" basename or full name is included in the list g:pathogen_blacklist or the
|
||||
" comma delimited environment variable $VIMBLACKLIST.
|
||||
function! pathogen#is_disabled(path) abort
|
||||
if a:path =~# '\~$'
|
||||
return 1
|
||||
endif
|
||||
let sep = pathogen#slash()
|
||||
let blacklist = get(g:, 'pathogen_blacklist', get(g:, 'pathogen_disabled', [])) + pathogen#split($VIMBLACKLIST)
|
||||
if !empty(blacklist)
|
||||
call map(blacklist, 'substitute(v:val, "[\\/]$", "", "")')
|
||||
endif
|
||||
return index(blacklist, fnamemodify(a:path, ':t')) != -1 || index(blacklist, a:path) != -1
|
||||
endfunction
|
||||
|
||||
" Prepend the given directory to the runtime path and append its corresponding
|
||||
" after directory. Curly braces are expanded with pathogen#expand().
|
||||
function! pathogen#surround(path) abort
|
||||
let sep = pathogen#slash()
|
||||
let rtp = pathogen#split(&rtp)
|
||||
let path = fnamemodify(a:path, ':s?[\\/]\=$??')
|
||||
let before = filter(pathogen#expand(path), '!pathogen#is_disabled(v:val)')
|
||||
let after = filter(reverse(pathogen#expand(path, sep.'after')), '!pathogen#is_disabled(v:val[0:-7])')
|
||||
call filter(rtp, 'index(before + after, v:val) == -1')
|
||||
let &rtp = pathogen#join(before, rtp, after)
|
||||
return &rtp
|
||||
endfunction
|
||||
|
||||
" For each directory in the runtime path, add a second entry with the given
|
||||
" argument appended. Curly braces are expanded with pathogen#expand().
|
||||
function! pathogen#interpose(name) abort
|
||||
let sep = pathogen#slash()
|
||||
let name = a:name
|
||||
if has_key(s:done_bundles, name)
|
||||
return ""
|
||||
endif
|
||||
let s:done_bundles[name] = 1
|
||||
let list = []
|
||||
for dir in pathogen#split(&rtp)
|
||||
if dir =~# '\<after$'
|
||||
let list += reverse(filter(pathogen#expand(dir[0:-6].name, sep.'after'), '!pathogen#is_disabled(v:val[0:-7])')) + [dir]
|
||||
else
|
||||
let list += [dir] + filter(pathogen#expand(dir.sep.name), '!pathogen#is_disabled(v:val)')
|
||||
endif
|
||||
endfor
|
||||
let &rtp = pathogen#join(pathogen#uniq(list))
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
let s:done_bundles = {}
|
||||
|
||||
" Invoke :helptags on all non-$VIM doc directories in runtimepath.
|
||||
function! pathogen#helptags() abort
|
||||
let sep = pathogen#slash()
|
||||
for glob in pathogen#split(&rtp)
|
||||
for dir in map(split(glob(glob), "\n"), 'v:val.sep."/doc/".sep')
|
||||
if (dir)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir) == 2 && !empty(split(glob(dir.'*.txt'))) && (!filereadable(dir.'tags') || filewritable(dir.'tags'))
|
||||
silent! execute 'helptags' pathogen#fnameescape(dir)
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
command! -bar Helptags :call pathogen#helptags()
|
||||
|
||||
" Execute the given command. This is basically a backdoor for --remote-expr.
|
||||
function! pathogen#execute(...) abort
|
||||
for command in a:000
|
||||
execute command
|
||||
endfor
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Section: Unofficial
|
||||
|
||||
function! pathogen#is_absolute(path) abort
|
||||
return a:path =~# (has('win32') ? '^\%([\\/]\|\w:\)[\\/]\|^[~$]' : '^[/~$]')
|
||||
endfunction
|
||||
|
||||
" Given a string, returns all possible permutations of comma delimited braced
|
||||
" alternatives of that string. pathogen#expand('/{a,b}/{c,d}') yields
|
||||
" ['/a/c', '/a/d', '/b/c', '/b/d']. Empty braces are treated as a wildcard
|
||||
" and globbed. Actual globs are preserved.
|
||||
function! pathogen#expand(pattern, ...) abort
|
||||
let after = a:0 ? a:1 : ''
|
||||
let pattern = substitute(a:pattern, '^[~$][^\/]*', '\=expand(submatch(0))', '')
|
||||
if pattern =~# '{[^{}]\+}'
|
||||
let [pre, pat, post] = split(substitute(pattern, '\(.\{-\}\){\([^{}]\+\)}\(.*\)', "\\1\001\\2\001\\3", ''), "\001", 1)
|
||||
let found = map(split(pat, ',', 1), 'pre.v:val.post')
|
||||
let results = []
|
||||
for pattern in found
|
||||
call extend(results, pathogen#expand(pattern))
|
||||
endfor
|
||||
elseif pattern =~# '{}'
|
||||
let pat = matchstr(pattern, '^.*{}[^*]*\%($\|[\\/]\)')
|
||||
let post = pattern[strlen(pat) : -1]
|
||||
let results = map(split(glob(substitute(pat, '{}', '*', 'g')), "\n"), 'v:val.post')
|
||||
else
|
||||
let results = [pattern]
|
||||
endif
|
||||
let vf = pathogen#slash() . 'vimfiles'
|
||||
call map(results, 'v:val =~# "\\*" ? v:val.after : isdirectory(v:val.vf.after) ? v:val.vf.after : isdirectory(v:val.after) ? v:val.after : ""')
|
||||
return filter(results, '!empty(v:val)')
|
||||
endfunction
|
||||
|
||||
" \ on Windows unless shellslash is set, / everywhere else.
|
||||
function! pathogen#slash() abort
|
||||
return !exists("+shellslash") || &shellslash ? '/' : '\'
|
||||
endfunction
|
||||
|
||||
function! pathogen#separator() abort
|
||||
return pathogen#slash()
|
||||
endfunction
|
||||
|
||||
" Convenience wrapper around glob() which returns a list.
|
||||
function! pathogen#glob(pattern) abort
|
||||
let files = split(glob(a:pattern),"\n")
|
||||
return map(files,'substitute(v:val,"[".pathogen#slash()."/]$","","")')
|
||||
endfunction
|
||||
|
||||
" Like pathogen#glob(), only limit the results to directories.
|
||||
function! pathogen#glob_directories(pattern) abort
|
||||
return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
|
||||
endfunction
|
||||
|
||||
" Remove duplicates from a list.
|
||||
function! pathogen#uniq(list) abort
|
||||
let i = 0
|
||||
let seen = {}
|
||||
while i < len(a:list)
|
||||
if (a:list[i] ==# '' && exists('empty')) || has_key(seen,a:list[i])
|
||||
call remove(a:list,i)
|
||||
elseif a:list[i] ==# ''
|
||||
let i += 1
|
||||
let empty = 1
|
||||
else
|
||||
let seen[a:list[i]] = 1
|
||||
let i += 1
|
||||
endif
|
||||
endwhile
|
||||
return a:list
|
||||
endfunction
|
||||
|
||||
" Backport of fnameescape().
|
||||
function! pathogen#fnameescape(string) abort
|
||||
if exists('*fnameescape')
|
||||
return fnameescape(a:string)
|
||||
elseif a:string ==# '-'
|
||||
return '\-'
|
||||
else
|
||||
return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Like findfile(), but hardcoded to use the runtimepath.
|
||||
function! pathogen#runtime_findfile(file,count) abort
|
||||
let rtp = pathogen#join(1,pathogen#split(&rtp))
|
||||
let file = findfile(a:file,rtp,a:count)
|
||||
if file ==# ''
|
||||
return ''
|
||||
else
|
||||
return fnamemodify(file,':p')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" vim:set et sw=2 foldmethod=expr foldexpr=getline(v\:lnum)=~'^\"\ Section\:'?'>1'\:getline(v\:lnum)=~#'^fu'?'a1'\:getline(v\:lnum)=~#'^endf'?'s1'\:'=':
|
|
@ -38,9 +38,12 @@ Cache
|
|||
# pypirc
|
||||
!/.pypirc
|
||||
|
||||
# vimrc
|
||||
# nvim
|
||||
!/.vimrc
|
||||
!/.vim
|
||||
!/.config/nvim
|
||||
/.vim/.netrwhist
|
||||
/.config/nvim/bundle
|
||||
|
||||
# fish config files
|
||||
!/.config/fish
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
let g:netrw_dirhistmax =10
|
||||
let g:netrw_dirhist_cnt =2
|
||||
let g:netrw_dirhist_1='/home/odrling/.config/mpv/scripts'
|
||||
let g:netrw_dirhist_2='/home/odrling/.sv/animeido/log'
|
450
.vimrc
450
.vimrc
|
@ -1,450 +0,0 @@
|
|||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Maintainer:
|
||||
" Amir Salihefendic — @amix3k
|
||||
"
|
||||
" Awesome_version:
|
||||
" Get this config, nice color schemes and lots of plugins!
|
||||
"
|
||||
" Install the awesome version from:
|
||||
"
|
||||
" https://github.com/amix/vimrc
|
||||
"
|
||||
" Sections:
|
||||
" -> General
|
||||
" -> VIM user interface
|
||||
" -> Colors and Fonts
|
||||
" -> Files and backups
|
||||
" -> Text, tab and indent related
|
||||
" -> Visual mode related
|
||||
" -> Moving around, tabs and buffers
|
||||
" -> Status line
|
||||
" -> Editing mappings
|
||||
" -> vimgrep searching and cope displaying
|
||||
" -> Spell checking
|
||||
" -> Misc
|
||||
" -> Helper functions
|
||||
"
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => General
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Sets how many lines of history VIM has to remember
|
||||
set history=500
|
||||
set number relativenumber
|
||||
|
||||
" Enable filetype plugins
|
||||
filetype plugin on
|
||||
filetype indent on
|
||||
|
||||
" fuzzy search
|
||||
set path+=**
|
||||
set wildmenu
|
||||
|
||||
" Set to auto read when a file is changed from the outside
|
||||
set autoread
|
||||
|
||||
" With a map leader it's possible to do extra key combinations
|
||||
" like <leader>w saves the current file
|
||||
let mapleader = ","
|
||||
|
||||
" Fast saving
|
||||
nmap <leader>w :w!<cr>
|
||||
nmap <leader>j :wn<cr>
|
||||
nmap <leader>k :wN<cr>
|
||||
nmap <leader>; A;<esc>
|
||||
nmap <leader>b :w<CR>:b<SPACE>
|
||||
|
||||
" :W sudo saves the file
|
||||
" (useful for handling the permission-denied error)
|
||||
command W w !sudo tee % > /dev/null
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => VIM user interface
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Set 5 lines to the cursor - when moving vertically using j/k
|
||||
set so=5
|
||||
|
||||
" Avoid garbled characters in Chinese language windows OS
|
||||
let $LANG='en'
|
||||
set langmenu=en
|
||||
source $VIMRUNTIME/delmenu.vim
|
||||
source $VIMRUNTIME/menu.vim
|
||||
|
||||
" Turn on the Wild menu
|
||||
set wildmenu
|
||||
|
||||
" Ignore compiled files
|
||||
set wildignore=*.o,*~,*.pyc
|
||||
if has("win16") || has("win32")
|
||||
set wildignore+=.git\*,.hg\*,.svn\*
|
||||
else
|
||||
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
|
||||
endif
|
||||
|
||||
"Always show current position
|
||||
set ruler
|
||||
|
||||
" Height of the command bar
|
||||
set cmdheight=1
|
||||
|
||||
" A buffer becomes hidden when it is abandoned
|
||||
set hid
|
||||
|
||||
" Configure backspace so it acts as it should act
|
||||
set backspace=eol,start,indent
|
||||
set whichwrap+=<,>,h,l
|
||||
|
||||
" Ignore case when searching
|
||||
set ignorecase
|
||||
|
||||
" When searching try to be smart about cases
|
||||
set smartcase
|
||||
|
||||
" Highlight search results
|
||||
set hlsearch
|
||||
|
||||
" Makes search act like search in modern browsers
|
||||
set incsearch
|
||||
|
||||
" Don't redraw while executing macros (good performance config)
|
||||
set lazyredraw
|
||||
|
||||
" For regular expressions turn magic on
|
||||
set magic
|
||||
|
||||
" Show matching brackets when text indicator is over them
|
||||
set showmatch
|
||||
" How many tenths of a second to blink when matching brackets
|
||||
set mat=2
|
||||
|
||||
" No annoying sound on errors
|
||||
set noerrorbells
|
||||
set novisualbell
|
||||
set t_vb=
|
||||
set tm=500
|
||||
|
||||
" Properly disable sound on errors on MacVim
|
||||
if has("gui_macvim")
|
||||
autocmd GUIEnter * set vb t_vb=
|
||||
endif
|
||||
|
||||
|
||||
" Add a bit extra margin to the left
|
||||
set foldcolumn=1
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Colors and Fonts
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Enable syntax highlighting
|
||||
syntax enable
|
||||
|
||||
" Enable 256 colors palette in Gnome Terminal
|
||||
" if $COLORTERM == 'gnome-terminal'
|
||||
" set t_Co=256
|
||||
" endif
|
||||
|
||||
try
|
||||
colorscheme desert
|
||||
catch
|
||||
endtry
|
||||
|
||||
let g:airline_theme='minimalist'
|
||||
|
||||
set background=dark
|
||||
|
||||
" Set extra options when running in GUI mode
|
||||
if has("gui_running")
|
||||
set guioptions-=T
|
||||
set guioptions-=e
|
||||
set t_Co=256
|
||||
set guitablabel=%M\ %t
|
||||
endif
|
||||
|
||||
" Set utf8 as standard encoding and en_US as the standard language
|
||||
set encoding=utf8
|
||||
|
||||
" Use Unix as the standard file type
|
||||
set ffs=unix,dos,mac
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Files, backups and undo
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Turn backup off, since most stuff is in SVN, git et.c anyway...
|
||||
set nobackup
|
||||
set nowb
|
||||
set noswapfile
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Text, tab and indent related
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Use spaces instead of tabs
|
||||
set expandtab
|
||||
|
||||
" Be smart when using tabs ;)
|
||||
set smarttab
|
||||
|
||||
" 1 tab == 4 spaces
|
||||
set shiftwidth=4
|
||||
set tabstop=4
|
||||
|
||||
" Linebreak on 500 characters
|
||||
set lbr
|
||||
set tw=500
|
||||
|
||||
set ai "Auto indent
|
||||
set si "Smart indent
|
||||
set wrap "Wrap lines
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""
|
||||
" => Visual mode related
|
||||
""""""""""""""""""""""""""""""
|
||||
" Visual mode pressing * or # searches for the current selection
|
||||
" Super useful! From an idea by Michael Naumann
|
||||
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
|
||||
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Moving around, tabs, windows and buffers
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Map <Space> to / (search) and Ctrl-<Space> to ? (backwards search)
|
||||
"map <space> /
|
||||
"map <c-space> ?
|
||||
|
||||
" Disable highlight when <leader><cr> is pressed
|
||||
map <silent> <leader><cr> :noh<cr>
|
||||
|
||||
" Smart way to move between windows
|
||||
map <C-j> <C-W>j
|
||||
map <C-k> <C-W>k
|
||||
map <C-h> <C-W>h
|
||||
map <C-l> <C-W>l
|
||||
|
||||
" Close the current buffer
|
||||
map <leader>bd :Bclose<cr>:tabclose<cr>gT
|
||||
|
||||
" Close all the buffers
|
||||
map <leader>ba :bufdo bd<cr>
|
||||
|
||||
map <leader>l :bnext<cr>
|
||||
map <leader>h :bprevious<cr>
|
||||
|
||||
" Useful mappings for managing tabs
|
||||
map <leader>tn :tabnew<cr>
|
||||
map <leader>to :tabonly<cr>
|
||||
map <leader>tc :tabclose<cr>
|
||||
map <leader>tm :tabmove
|
||||
map <leader>t<leader> :tabnext
|
||||
|
||||
" Let 'tl' toggle between this and the last accessed tab
|
||||
let g:lasttab = 1
|
||||
nmap <Leader>tl :exe "tabn ".g:lasttab<CR>
|
||||
au TabLeave * let g:lasttab = tabpagenr()
|
||||
|
||||
|
||||
" Opens a new tab with the current buffer's path
|
||||
" Super useful when editing files in the same directory
|
||||
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
|
||||
|
||||
" Switch CWD to the directory of the open buffer
|
||||
map <leader>cd :cd %:p:h<cr>:pwd<cr>
|
||||
|
||||
" Specify the behavior when switching between buffers
|
||||
try
|
||||
set switchbuf=useopen,usetab,newtab
|
||||
set stal=2
|
||||
catch
|
||||
endtry
|
||||
|
||||
" Return to last edit position when opening files (You want this!)
|
||||
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
|
||||
|
||||
|
||||
""""""""""""""""""""""""""""""
|
||||
" => Status line
|
||||
""""""""""""""""""""""""""""""
|
||||
" Always show the status line
|
||||
set laststatus=2
|
||||
|
||||
" Format the status line
|
||||
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Editing mappings
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Remap VIM 0 to first non-blank character
|
||||
map 0 ^
|
||||
|
||||
" Move a line of text using ALT+[jk] or Command+[jk] on mac
|
||||
nmap <M-j> mz:m+<cr>`z
|
||||
nmap <M-k> mz:m-2<cr>`z
|
||||
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
|
||||
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
|
||||
|
||||
if has("mac") || has("macunix")
|
||||
nmap <D-j> <M-j>
|
||||
nmap <D-k> <M-k>
|
||||
vmap <D-j> <M-j>
|
||||
vmap <D-k> <M-k>
|
||||
endif
|
||||
|
||||
" Delete trailing white space on save, useful for some filetypes ;)
|
||||
fun! CleanExtraSpaces()
|
||||
let save_cursor = getpos(".")
|
||||
let old_query = getreg('/')
|
||||
silent! %s/\s\+$//e
|
||||
call setpos('.', save_cursor)
|
||||
call setreg('/', old_query)
|
||||
endfun
|
||||
|
||||
if has("autocmd")
|
||||
autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee,*.adb,*ads :call CleanExtraSpaces()
|
||||
endif
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Spell checking
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Pressing ,ss will toggle and untoggle spell checking
|
||||
map <leader>ss :setlocal spell!<cr>
|
||||
|
||||
" Shortcuts using <leader>
|
||||
map <leader>sn ]s
|
||||
map <leader>sp [s
|
||||
map <leader>sa zg
|
||||
map <leader>s? z=
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Misc
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" git
|
||||
noremap <C-z> :Gw<CR>
|
||||
noremap <C-c> :Gcommit<CR>
|
||||
|
||||
" Remove the Windows ^M - when the encodings gets messed up
|
||||
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
|
||||
|
||||
" turn off highlighting
|
||||
map <leader>h :noh<CR>
|
||||
|
||||
" Quickly open a buffer for scribble
|
||||
map <leader>q :e ~/buffer<cr>
|
||||
|
||||
" Quickly open a markdown buffer for scribble
|
||||
map <leader>x :e ~/buffer.md<cr>
|
||||
|
||||
" Toggle paste mode on and off
|
||||
map <leader>pp :setlocal paste!<cr>
|
||||
|
||||
" Move to the next marker
|
||||
inoremap <C-j> <Esc>/<++><CR>"_c4l
|
||||
inoremap <C-j><C-j> <++>
|
||||
nnoremap <Space> a<++><ESC>
|
||||
|
||||
" file completion
|
||||
inoremap <C-f> <C-x><C-f>
|
||||
|
||||
" tag completion
|
||||
inoremap <C-]> <C-x><C-]>
|
||||
|
||||
" create line above
|
||||
inoremap <S-Enter> <Esc>O
|
||||
|
||||
" adathings
|
||||
autocmd FileType ada ab if if then<CR><++><CR>end if;<CR><++><Esc>3k0ea
|
||||
autocmd FileType ada ab while while loop<CR><++><CR>end loop;<CR><++><Esc>3k0ea
|
||||
autocmd FileType ada ab for for loop<CR><++><CR>end loop;<CR><++><Esc>3k0ea
|
||||
autocmd FileType ada ab proc procedure is<CR>begin<CR><++><CR>end;<CR><++><ESC>4k^ea
|
||||
autocmd FileType ada ab pros procedure;<CR><++><ESC>k^ea
|
||||
autocmd FileType ada ab func function(<++>) return <++><CR>end;<CR><++><ESC>3kea
|
||||
autocmd FileType ada ab funs function(<++>) return <++>;<CR><++><ESC>k^ea
|
||||
autocmd FileType ada ab pack package is<CR><++><CR>end;<CR><++><ESC>3kea
|
||||
autocmd FileType ada ab use use <ESC>0wyf;$pa
|
||||
autocmd FileType ada ab case case is<CR>when others => <++><CR>end case;<ESC>2k^ea
|
||||
autocmd FileType ada ab loop loop<CR>end loop;<ESC>kA
|
||||
|
||||
" pythonthings
|
||||
autocmd FileType python map #! ggi#!/usr/bin/env python3<CR><ESC>:silent exec "!chmod +x %"<CR>
|
||||
autocmd FileType python map ;m oif __name__ == '__main__':<CR>main()<ESC>^
|
||||
autocmd FileType python ab try: except: <++>:<CR><++><ESC>2kotry:
|
||||
autocmd FileType python map <C-i> :w<CR>:silent exec "!isort %"<CR>:e %<CR>
|
||||
|
||||
" shellthings
|
||||
autocmd FileType sh map #! ggi#!/bin/sh<CR>
|
||||
autocmd FileType sh inoremap if if ; then<CR><++><CR>fi<CR><++><ESC>3k^ela
|
||||
autocmd FileType sh inoremap for for ; do<CR><++><CR>done<CR><++><ESC>3k^ela
|
||||
autocmd FileType sh inoremap while while ; do<CR><++><CR>done<CR><++><ESC>3k^ela
|
||||
|
||||
" html
|
||||
autocmd BufNewFile *.html 0r ~/.templates/html
|
||||
autocmd BufNewFile *.html exe "normal 3jf>l" | startinsert
|
||||
|
||||
" file browsing
|
||||
let g:netrw_banner=0 " disable the banner
|
||||
let g:netrw_liststyle=3 " tree view
|
||||
map <C-o> :edit .<CR>
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Helper functions
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Returns true if paste mode is enabled
|
||||
function! HasPaste()
|
||||
if &paste
|
||||
return 'PASTE MODE '
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Don't close window, when deleting a buffer
|
||||
command! Bclose call <SID>BufcloseCloseIt()
|
||||
function! <SID>BufcloseCloseIt()
|
||||
let l:currentBufNum = bufnr("%")
|
||||
let l:alternateBufNum = bufnr("#")
|
||||
|
||||
if buflisted(l:alternateBufNum)
|
||||
buffer #
|
||||
else
|
||||
bnext
|
||||
endif
|
||||
|
||||
if bufnr("%") == l:currentBufNum
|
||||
new
|
||||
endif
|
||||
|
||||
if buflisted(l:currentBufNum)
|
||||
execute("bdelete! ".l:currentBufNum)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! CmdLine(str)
|
||||
call feedkeys(":" . a:str)
|
||||
endfunction
|
||||
|
||||
function! VisualSelection(direction, extra_filter) range
|
||||
let l:saved_reg = @"
|
||||
execute "normal! vgvy"
|
||||
|
||||
let l:pattern = escape(@", "\\/.*'$^~[]")
|
||||
let l:pattern = substitute(l:pattern, "\n$", "", "")
|
||||
|
||||
if a:direction == 'gv'
|
||||
call CmdLine("Ack '" . l:pattern . "' " )
|
||||
elseif a:direction == 'replace'
|
||||
call CmdLine("%s" . '/'. l:pattern . '/')
|
||||
endif
|
||||
|
||||
let @/ = l:pattern
|
||||
let @" = l:saved_reg
|
||||
endfunction
|
||||
|
||||
execute pathogen#infect()
|
||||
|
Loading…
Reference in New Issue