[vim] moving functions/plugins to separate files
This commit is contained in:
87
vim/vim.symlink/functions.vim
Normal file
87
vim/vim.symlink/functions.vim
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
" Window movement shortcuts
|
||||||
|
" move to the window in the direction shown, or create a new window
|
||||||
|
function! WinMove(key)
|
||||||
|
let t:curwin = winnr()
|
||||||
|
exec "wincmd ".a:key
|
||||||
|
if (t:curwin == winnr())
|
||||||
|
if (match(a:key,'[jk]'))
|
||||||
|
wincmd v
|
||||||
|
else
|
||||||
|
wincmd s
|
||||||
|
endif
|
||||||
|
exec "wincmd ".a:key
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" toggle relative line numbers
|
||||||
|
function! ToggleNuMode()
|
||||||
|
if (&rnu == 1)
|
||||||
|
setlocal nu
|
||||||
|
else
|
||||||
|
setlocal rnu
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" tell me what syntax group the word below the cursor belongs to
|
||||||
|
function! <SID>SynStack()
|
||||||
|
if !exists("*synstack")
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" recursively search up from dirname, sourcing all .vimrc.local files along the way
|
||||||
|
function! ApplyLocalSettings(dirname)
|
||||||
|
" convert windows paths to unix style
|
||||||
|
let l:curDir = substitute(a:dirname, "\\", "/", "g")
|
||||||
|
|
||||||
|
" walk to the top of the dir tree
|
||||||
|
let l:parentDir = strpart(l:curDir, 0, strridx(l:curDir, "/"))
|
||||||
|
if isdirectory(l:parentDir)
|
||||||
|
call ApplyLocalSettings(l:parentDir)
|
||||||
|
endif
|
||||||
|
|
||||||
|
" now walk back down the path and source .vimsettings as you find them.
|
||||||
|
" child directories can inherit from their parents
|
||||||
|
let l:settingsFile = a:dirname . "/.vimrc.local"
|
||||||
|
if filereadable(l:settingsFile)
|
||||||
|
exec ":source" . l:settingsFile
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" smart tab completion
|
||||||
|
function! Smart_TabComplete()
|
||||||
|
let line = getline('.') " current line
|
||||||
|
|
||||||
|
let substr = strpart(line, -1, col('.')+1) " from the start of the current
|
||||||
|
" line to one character right
|
||||||
|
" of the cursor
|
||||||
|
let substr = matchstr(substr, "[^ \t]*$") " word till cursor
|
||||||
|
if (strlen(substr)==0) " nothing to match on empty string
|
||||||
|
return "\<tab>"
|
||||||
|
endif
|
||||||
|
let has_period = match(substr, '\.') != -1 " position of period, if any
|
||||||
|
let has_slash = match(substr, '\/') != -1 " position of slash, if any
|
||||||
|
if (!has_period && !has_slash)
|
||||||
|
return "\<C-X>\<C-P>" " existing text matching
|
||||||
|
elseif ( has_slash )
|
||||||
|
return "\<C-X>\<C-F>" " file matching
|
||||||
|
else
|
||||||
|
return "\<C-X>\<C-O>" " plugin matching
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" execute a custom command
|
||||||
|
function! RunCustomCommand()
|
||||||
|
up
|
||||||
|
if g:silent_custom_command
|
||||||
|
execute 'silent !' . s:customcommand
|
||||||
|
else
|
||||||
|
execute '!' . s:customcommand
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! SetCustomCommand()
|
||||||
|
let s:customcommand = input('Enter Custom Command$ ')
|
||||||
|
endfunction
|
||||||
|
|
||||||
39
vim/vim.symlink/plugins.vim
Normal file
39
vim/vim.symlink/plugins.vim
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
set rtp+=~/.vim/bundle/vundle/
|
||||||
|
call vundle#rc()
|
||||||
|
|
||||||
|
" let vundle manage vundle
|
||||||
|
Bundle 'gmarik/vundle'
|
||||||
|
|
||||||
|
" my vim plugins
|
||||||
|
Bundle 'kien/ctrlp.vim'
|
||||||
|
Bundle 'scrooloose/nerdtree'
|
||||||
|
Bundle 'mileszs/ack.vim'
|
||||||
|
Bundle 'Raimondi/delimitMate'
|
||||||
|
Bundle 'tpope/vim-commentary'
|
||||||
|
Bundle 'tpope/vim-unimpaired'
|
||||||
|
Bundle 'tpope/vim-endwise'
|
||||||
|
Bundle 'tpope/vim-fugitive'
|
||||||
|
Bundle 'othree/html5.vim'
|
||||||
|
Bundle 'pangloss/vim-javascript'
|
||||||
|
Bundle 'itspriddle/vim-jquery'
|
||||||
|
Bundle 'tpope/vim-markdown'
|
||||||
|
Bundle 'mmalecki/vim-node.js'
|
||||||
|
" Bundle 'Lokaltog/vim-powerline'
|
||||||
|
Bundle 'tpope/vim-ragtag'
|
||||||
|
Bundle 'tpope/vim-surround'
|
||||||
|
Bundle 'duff/vim-scratch'
|
||||||
|
" Bundle 'sjl/vitality.vim'
|
||||||
|
Bundle 'cakebaker/scss-syntax.vim'
|
||||||
|
Bundle 'kchmck/vim-coffee-script'
|
||||||
|
Bundle 'groenewege/vim-less'
|
||||||
|
Bundle 'tsaleh/vim-matchit'
|
||||||
|
Bundle 'benmills/vimux'
|
||||||
|
Bundle 'mattn/zencoding-vim'
|
||||||
|
Bundle 'ap/vim-css-color'
|
||||||
|
" Bundle 'nicknisi/ir-whack'
|
||||||
|
Bundle 'flazz/vim-colorschemes'
|
||||||
|
Bundle 'editorconfig/editorconfig-vim'
|
||||||
|
Bundle 'juvenn/mustache.vim'
|
||||||
|
Bundle 'tclem/vim-arduino'
|
||||||
|
Bundle 'bling/vim-airline'
|
||||||
|
" Bundle 'scrooloose/syntastic'
|
||||||
@@ -2,46 +2,7 @@
|
|||||||
|
|
||||||
if (!exists('vimrc_already_sourced'))
|
if (!exists('vimrc_already_sourced'))
|
||||||
filetype off
|
filetype off
|
||||||
set rtp+=~/.vim/bundle/vundle/
|
source ~/.vim/plugins.vim
|
||||||
call vundle#rc()
|
|
||||||
|
|
||||||
" let vundle manage vundle
|
|
||||||
Bundle 'gmarik/vundle'
|
|
||||||
|
|
||||||
" my vim plugins
|
|
||||||
Bundle 'kien/ctrlp.vim'
|
|
||||||
Bundle 'scrooloose/nerdtree'
|
|
||||||
Bundle 'mileszs/ack.vim'
|
|
||||||
Bundle 'Raimondi/delimitMate'
|
|
||||||
Bundle 'tpope/vim-commentary'
|
|
||||||
Bundle 'tpope/vim-unimpaired'
|
|
||||||
Bundle 'tpope/vim-endwise'
|
|
||||||
Bundle 'tpope/vim-fugitive'
|
|
||||||
Bundle 'othree/html5.vim'
|
|
||||||
Bundle 'pangloss/vim-javascript'
|
|
||||||
Bundle 'itspriddle/vim-jquery'
|
|
||||||
Bundle 'tpope/vim-markdown'
|
|
||||||
Bundle 'mmalecki/vim-node.js'
|
|
||||||
" Bundle 'Lokaltog/vim-powerline'
|
|
||||||
Bundle 'tpope/vim-ragtag'
|
|
||||||
Bundle 'tpope/vim-surround'
|
|
||||||
Bundle 'duff/vim-scratch'
|
|
||||||
" Bundle 'sjl/vitality.vim'
|
|
||||||
Bundle 'cakebaker/scss-syntax.vim'
|
|
||||||
Bundle 'kchmck/vim-coffee-script'
|
|
||||||
Bundle 'groenewege/vim-less'
|
|
||||||
Bundle 'tsaleh/vim-matchit'
|
|
||||||
Bundle 'benmills/vimux'
|
|
||||||
Bundle 'mattn/zencoding-vim'
|
|
||||||
Bundle 'ap/vim-css-color'
|
|
||||||
" Bundle 'nicknisi/ir-whack'
|
|
||||||
Bundle 'flazz/vim-colorschemes'
|
|
||||||
Bundle 'editorconfig/editorconfig-vim'
|
|
||||||
Bundle 'juvenn/mustache.vim'
|
|
||||||
Bundle 'tclem/vim-arduino'
|
|
||||||
Bundle 'bling/vim-airline'
|
|
||||||
" Bundle 'scrooloose/syntastic'
|
|
||||||
|
|
||||||
filetype plugin indent on
|
filetype plugin indent on
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -50,6 +11,9 @@ endif
|
|||||||
" => General
|
" => General
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
|
||||||
|
" load functions
|
||||||
|
source ~/.vim/functions.vim
|
||||||
|
|
||||||
"""" Abbreviations
|
"""" Abbreviations
|
||||||
abbr funciton function
|
abbr funciton function
|
||||||
abbr teh the
|
abbr teh the
|
||||||
@@ -94,7 +58,8 @@ set ttyfast
|
|||||||
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
|
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
|
||||||
|
|
||||||
" file type specific settings
|
" file type specific settings
|
||||||
if has("autocmd")
|
if has("autocmd") && !exists("autocommands_loaded")
|
||||||
|
let autocommands_loaded = 1
|
||||||
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
|
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
|
||||||
autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
|
autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
|
||||||
autocmd FileType ruby setlocal ts=2 sts=2 sw=2 expandtab
|
autocmd FileType ruby setlocal ts=2 sts=2 sw=2 expandtab
|
||||||
@@ -250,21 +215,6 @@ nmap <leader>. <c-^>
|
|||||||
" enable . command in visual mode
|
" enable . command in visual mode
|
||||||
vnoremap . :normal .<cr>
|
vnoremap . :normal .<cr>
|
||||||
|
|
||||||
" Window movement shortcuts
|
|
||||||
" move to the window in the direction shown, or create a new window
|
|
||||||
function! WinMove(key)
|
|
||||||
let t:curwin = winnr()
|
|
||||||
exec "wincmd ".a:key
|
|
||||||
if (t:curwin == winnr())
|
|
||||||
if (match(a:key,'[jk]'))
|
|
||||||
wincmd v
|
|
||||||
else
|
|
||||||
wincmd s
|
|
||||||
endif
|
|
||||||
exec "wincmd ".a:key
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
map <silent> <C-h> :call WinMove('h')<cr>
|
map <silent> <C-h> :call WinMove('h')<cr>
|
||||||
map <silent> <C-j> :call WinMove('j')<cr>
|
map <silent> <C-j> :call WinMove('j')<cr>
|
||||||
map <silent> <C-k> :call WinMove('k')<cr>
|
map <silent> <C-k> :call WinMove('k')<cr>
|
||||||
@@ -286,84 +236,18 @@ nnoremap <C-y> 3<C-y>
|
|||||||
nnoremap <silent> j gj
|
nnoremap <silent> j gj
|
||||||
nnoremap <silent> k gk
|
nnoremap <silent> k gk
|
||||||
|
|
||||||
function! ToggleNuMode()
|
|
||||||
if (&rnu == 1)
|
|
||||||
setlocal nu
|
|
||||||
else
|
|
||||||
setlocal rnu
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
nnoremap <leader>/ :call ToggleNuMode()<cr>
|
nnoremap <leader>/ :call ToggleNuMode()<cr>
|
||||||
|
|
||||||
" find out what syntax stack a statement belongs to
|
" find out what syntax stack a statement belongs to
|
||||||
nmap <leader>s :call <SID>SynStack()<cr>
|
nmap <leader>s :call <SID>SynStack()<cr>
|
||||||
function! <SID>SynStack()
|
|
||||||
if !exists("*synstack")
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! ApplyLocalSettings(dirname)
|
|
||||||
" convert windows paths to unix style
|
|
||||||
let l:curDir = substitute(a:dirname, "\\", "/", "g")
|
|
||||||
|
|
||||||
" walk to the top of the dir tree
|
|
||||||
let l:parentDir = strpart(l:curDir, 0, strridx(l:curDir, "/"))
|
|
||||||
if isdirectory(l:parentDir)
|
|
||||||
call ApplyLocalSettings(l:parentDir)
|
|
||||||
endif
|
|
||||||
|
|
||||||
" now walk back down the path and source .vimsettings as you find them.
|
|
||||||
" child directories can inherit from their parents
|
|
||||||
let l:settingsFile = a:dirname . "/.vimrc.local"
|
|
||||||
if filereadable(l:settingsFile)
|
|
||||||
exec ":source" . l:settingsFile
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
autocmd! BufEnter * call ApplyLocalSettings(expand("<afile>:p:h"))
|
autocmd! BufEnter * call ApplyLocalSettings(expand("<afile>:p:h"))
|
||||||
|
|
||||||
" smart tab completion
|
|
||||||
function! Smart_TabComplete()
|
|
||||||
let line = getline('.') " current line
|
|
||||||
|
|
||||||
let substr = strpart(line, -1, col('.')+1) " from the start of the current
|
|
||||||
" line to one character right
|
|
||||||
" of the cursor
|
|
||||||
let substr = matchstr(substr, "[^ \t]*$") " word till cursor
|
|
||||||
if (strlen(substr)==0) " nothing to match on empty string
|
|
||||||
return "\<tab>"
|
|
||||||
endif
|
|
||||||
let has_period = match(substr, '\.') != -1 " position of period, if any
|
|
||||||
let has_slash = match(substr, '\/') != -1 " position of slash, if any
|
|
||||||
if (!has_period && !has_slash)
|
|
||||||
return "\<C-X>\<C-P>" " existing text matching
|
|
||||||
elseif ( has_slash )
|
|
||||||
return "\<C-X>\<C-F>" " file matching
|
|
||||||
else
|
|
||||||
return "\<C-X>\<C-O>" " plugin matching
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
inoremap <tab> <c-r>=Smart_TabComplete()<CR>
|
inoremap <tab> <c-r>=Smart_TabComplete()<CR>
|
||||||
|
|
||||||
map <leader>r :call RunCustomCommand()<cr>
|
map <leader>r :call RunCustomCommand()<cr>
|
||||||
map <leader>s :call SetCustomCommand()<cr>
|
map <leader>s :call SetCustomCommand()<cr>
|
||||||
let g:silent_custom_command = 0
|
let g:silent_custom_command = 0
|
||||||
|
|
||||||
function! RunCustomCommand()
|
|
||||||
up
|
|
||||||
if g:silent_custom_command
|
|
||||||
execute 'silent !' . s:customcommand
|
|
||||||
else
|
|
||||||
execute '!' . s:customcommand
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! SetCustomCommand()
|
|
||||||
let s:customcommand = input('Enter Custom Command$ ')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
" => Plugins
|
" => Plugins
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
|||||||
Reference in New Issue
Block a user