More vim ctag improvements
This commit is contained in:
parent
afc89a1725
commit
3d91c1d4f0
7
aliases
7
aliases
|
@ -970,9 +970,12 @@ alias gwip="git add . && git commit -m \"WIP\""
|
|||
####################################################################################################
|
||||
# Elixir
|
||||
####################################################################################################
|
||||
alias ei='rlwrap iex -S mix phx.server'
|
||||
alias et='mix test'
|
||||
alias iex='rlwrap iex'
|
||||
alias iexw='rlwrap iex --werl'
|
||||
alias ep='iex -S mix phx.server'
|
||||
alias ei='iex -S mix'
|
||||
alias er='mix phx.server'
|
||||
alias et='mix test'
|
||||
|
||||
####################################################################################################
|
||||
# Haxe
|
||||
|
|
85
vimrc
85
vimrc
|
@ -118,20 +118,33 @@ let g:campo_custom_search_args = ""
|
|||
""""""""""""""
|
||||
" CTAGS
|
||||
""""""""""""""
|
||||
" If one of these file types are saved then the ctags creation function will be called.
|
||||
let g:campo_extensions_that_run_ctags = "*.{cs,js,py,h,hpp,c,cpp,inc,asm,ex,exs}"
|
||||
|
||||
" Default files and directories that ctags should ignore.
|
||||
let g:default_ctags_exclude_args = "--exclude=.git --exclude=*.md --exclude=*.txt --exclude=*.config --exclude=*.css --exclude=*.html --exclude=*.htm --exclude=*.json --exclude=node_modules --exclude=.cache"
|
||||
" If != 0 then ctag generation will always happen on a file save, otherwise
|
||||
" it'll only be triggered if the file being saved has an extension in the
|
||||
" g:campo_extensions_that_run_ctags list.
|
||||
let g:campo_force_ctags_regardless_of_extension = 0
|
||||
|
||||
" If one of these file types are saved then the ctags creation function will be called.
|
||||
" You can append to this list in another config like so:
|
||||
" let g:campo_extensions_that_run_ctags = g:campo_extensions_that_run_ctags + ['foo', 'bar']
|
||||
let g:campo_extensions_that_run_ctags = ['c','cpp','h','hpp','inc','cs','js','py','asm','ex','exs']
|
||||
|
||||
" Default files and directories that ctags should ignore when doing a
|
||||
" recursive crawl.
|
||||
" @note The RunCtags function will always ignore .git and node_modules
|
||||
" regardless of this variable's value.
|
||||
let g:campo_ctags_exclude = ['*.txt', '*.config', '.cache']
|
||||
|
||||
" This is included in the ctags autocmd args. You can use this to customize
|
||||
" how ctags are built. For example, you can exclude a directory that's not in
|
||||
" g:default_ctags_exclude_args like so (remove the backslash from the first
|
||||
" quote as that's just here to escape it in this comment string)
|
||||
" let g:campo_custom_ctags_args = \"--exclude=3rd_party"
|
||||
" how ctags are built.
|
||||
" Examples:
|
||||
" * Recursive ctag generation with `let g:campo_custom_ctags_args = '-R'`
|
||||
" * Create tags for specific langauges: `let g:campo_custom_ctags_args = '--languages=C,C++,Elixir'
|
||||
" * You can see a list of languages with `ctags --list-languages`
|
||||
" * For C# you have to escape the ampersand like so: `--languages=C\\#`
|
||||
" * Exclude a directory with `let g:campo_custom_ctags_args = '--exclude=3rd_party'`
|
||||
let g:campo_custom_ctags_args = ""
|
||||
|
||||
|
||||
"################################################################
|
||||
"################################################################
|
||||
"################################################################
|
||||
|
@ -518,22 +531,52 @@ augroup campoCmds
|
|||
autocmd BufWritePost ~/.vimrc.private source $MYVIMRC
|
||||
|
||||
function! s:RunCtags()
|
||||
" The ampersand at the end is to make this run in the background. I had to
|
||||
" group the commands in parens to make the chained commands run in the
|
||||
" background.
|
||||
" Only allow one instance of ctags to run in this directory at any given time.
|
||||
let l:lock_file = "ctags.lock"
|
||||
if !filereadable(l:lock_file) && !filereadable("newtags")
|
||||
" Will include local variables for C-like languages.
|
||||
let l:ctags_cmd = "!(touch ".l:lock_file."; ctags --c-types=+l --c++-types=+l ".g:default_ctags_exclude_args." ". g:campo_custom_ctags_args." --recurse=yes -o newtags; mv newtags tags; rm ".l:lock_file.") &"
|
||||
silent! exec l:ctags_cmd | redraw!
|
||||
else
|
||||
call PrintError("ctags already running (found ".l:lock_file.")")
|
||||
if filereadable(l:lock_file) || filereadable("newtags")
|
||||
call PrintError("ctags already running (found ".l:lock_file." or newtags file)")
|
||||
return
|
||||
endif
|
||||
|
||||
let l:extension = tolower(expand('%:e'))
|
||||
if (g:campo_force_ctags_regardless_of_extension == 0) && (index(g:campo_extensions_that_run_ctags, l:extension) < 0)
|
||||
echo "Skipping ctags generation"
|
||||
return
|
||||
endif
|
||||
|
||||
" Abort if we're editing a text file. This won't be an exhaustive
|
||||
" filter. We can restrict what goes into the tag file
|
||||
" First determine if we're in a root drive directory. If we are then
|
||||
" we bail because we don't want to recurse across the entire drive!
|
||||
let l:path = expand('%:p:h')
|
||||
let l:path_without_slashes = substitute(l:path, "/", "", "g")
|
||||
if (strchars(l:path) - strchars(l:path_without_slashes)) <= 1
|
||||
call PrintError("Not going to run ctags because the file is in a root drive directory")
|
||||
return
|
||||
endif
|
||||
|
||||
" Always ignore .git and node_modules
|
||||
let g:campo_ctags_exclude = g:campo_ctags_exclude + ['.git', 'node_modules']
|
||||
let l:exclude_list = ""
|
||||
for name in g:campo_ctags_exclude
|
||||
let l:exclude_list = l:exclude_list . "--exclude=" . name . " "
|
||||
endfor
|
||||
|
||||
" Include local variables for C-like languages.
|
||||
let l:ctags_cmd = 'ctags '.l:exclude_list.' '.g:campo_custom_ctags_args.' --c-types=+l --c++-types=+l -o newtags'
|
||||
|
||||
" If there's an error running ctags then this echo will cause the
|
||||
" error msg to be displayed on a new line.
|
||||
echo ''
|
||||
|
||||
" The ampersand at the end is to make this run in the background. I had to group the
|
||||
" commands in parens to make the chained commands run in the background.
|
||||
let l:cmd = '!(touch '.l:lock_file.'; '.l:ctags_cmd.'; mv newtags tags &>/dev/null; rm '.l:lock_file.') &'
|
||||
silent! exec l:cmd
|
||||
endfun
|
||||
|
||||
" Generate ctags on save. In order to use the variable we have to put the
|
||||
" autocmd in an exec statement.
|
||||
exec "autocmd BufWritePost ".g:campo_extensions_that_run_ctags." call s:RunCtags()"
|
||||
" Generate ctags on save.
|
||||
autocmd BufWritePost * call s:RunCtags()
|
||||
|
||||
" Remove trailing whitespace when saving any file.
|
||||
function! s:StripTrailingWhitespaces()
|
||||
|
|
|
@ -213,8 +213,8 @@ processor time and is generally useless.
|
|||
|
||||
### Setting up ctags
|
||||
|
||||
* Install the latest Universal ctags build: https://github.com/universal-ctags/ctags-win32/releases
|
||||
* Place it in `~/bin`.
|
||||
* Download the latest Universal ctags build: https://github.com/universal-ctags/ctags-win32/releases
|
||||
* Place ctags.exe and readtags.exe in `~/bin` or in `~/.dev/tools`.
|
||||
|
||||
## Setting up Visual Studio
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user