Clean up vim search and import local jai modules when building
This commit is contained in:
parent
2640761dc5
commit
45d3fa244a
43
vimrc
43
vimrc
|
@ -662,7 +662,7 @@ function! s:CreateCtags()
|
|||
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 . " "
|
||||
let l:exclude_list .= "--exclude=" . name . " "
|
||||
endfor
|
||||
|
||||
" Include local variables for C-like languages.
|
||||
|
@ -671,7 +671,7 @@ function! s:CreateCtags()
|
|||
" Add the filename to the ctags command if not running in recursive mode.
|
||||
let l:recursive = matchstr(g:campo_custom_ctags_args, '\(-R\s\)\|\(-R$\)\|\(--recurse=yes\)\|\(--recurse\s\)\|\(--recurse$\)')
|
||||
if l:recursive == ''
|
||||
let l:ctags_cmd = l:ctags_cmd . ' ' . expand('%:t')
|
||||
let l:ctags_cmd .= ' ' . expand('%:t')
|
||||
echo "Creating non-recursive ctags"
|
||||
else
|
||||
echo "Creating recursive ctags"
|
||||
|
@ -910,7 +910,7 @@ let g:rg_window_height = g:quickfix_pane_height
|
|||
function! g:SetExtraCtagsPaths(paths_array)
|
||||
let l:list = './tags,tags' " This is the default tags list set by vim.
|
||||
for path in a:paths_array
|
||||
let l:list = l:list . ',' . path
|
||||
let l:list .= ',' . path
|
||||
endfor
|
||||
let &tags=l:list
|
||||
endfunction
|
||||
|
@ -955,7 +955,7 @@ function! CtrlP_JaiSearch(jai_rel_search_path)
|
|||
endif
|
||||
let l:path = g:campo_jai_path
|
||||
if a:jai_rel_search_path != ''
|
||||
let l:path = l:path. '/' . a:jai_rel_search_path
|
||||
let l:path .= '/' . a:jai_rel_search_path
|
||||
endif
|
||||
if !isdirectory(l:path)
|
||||
call PrintError("Directory ".l:path." doesn't exist.")
|
||||
|
@ -1306,12 +1306,19 @@ function! StopRunTask()
|
|||
endfunction
|
||||
|
||||
function! Build(optimized=0)
|
||||
let l:params = ''
|
||||
if tolower(expand('%:e')) == "jai"
|
||||
let l:params = ""
|
||||
let l:ext = tolower(expand('%:e'))
|
||||
if l:ext == "jai"
|
||||
" Jai build
|
||||
let l:cmd = "jai % "
|
||||
if a:optimized == 1
|
||||
let l:params .= '-release '
|
||||
let l:cmd .= "-release "
|
||||
endif
|
||||
exec "AsyncRun! -save=2 jai % " . l:params
|
||||
" If there's a local modules/ directory then we'll import it.
|
||||
if isdirectory(expand('%:p:h') . "/modules")
|
||||
let l:cmd .= "-import_dir modules "
|
||||
endif
|
||||
exec "AsyncRun! -save=2 " . l:cmd
|
||||
else
|
||||
if a:optimized == 1
|
||||
let l:params .= '-o '
|
||||
|
@ -1385,8 +1392,8 @@ nnoremap <C-p> :cp<CR>
|
|||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
" Search using ripgrep (first install with Rust: cargo install ripgrep).
|
||||
function! Search(case_sensitive, search_args)
|
||||
let l:helper = "Search [" . a:search_args . " | " . (a:case_sensitive ? "case-sensitive" : "case-insensitive") . "]: "
|
||||
function! Search(path, search_args, case_insensitive=0)
|
||||
let l:helper = "Search '" . a:path . "' (" . (len(a:search_args) > 0 ? a:search_args . " | " : '') . (a:case_insensitive ? "INSENSITIVE" : "SENSITIVE") . "): "
|
||||
let l:term = input(l:helper)
|
||||
if empty(l:term)
|
||||
return
|
||||
|
@ -1396,20 +1403,24 @@ function! Search(case_sensitive, search_args)
|
|||
"quickfix window doesn't seem to parse the ansi color codes.
|
||||
let l:rg_args = "--column --line-number --no-heading --fixed-strings --no-ignore --hidden --follow --trim -g \"!tags\" -g \"!.git/\" -g \"!AppData/\" " . a:search_args
|
||||
|
||||
if !a:case_sensitive
|
||||
if a:case_insensitive
|
||||
let l:rg_args .= " --ignore-case"
|
||||
endif
|
||||
|
||||
exec 'Rg ' . l:rg_args . ' -e "' . l:term . '"'
|
||||
exec 'Rg ' . l:rg_args . ' -e "' . l:term . '"' . ' ' . a:path
|
||||
endfunction
|
||||
|
||||
" Case insensitive
|
||||
noremap <leader>s :call Search(0, g:campo_custom_search_args)<cr>
|
||||
noremap <F2> :call Search(0, g:campo_custom_search_args_2)<cr>
|
||||
noremap <leader>s :call Search('.', g:campo_custom_search_args, 1)<cr>
|
||||
noremap <F2> :call Search('.', g:campo_custom_search_args, 1)<cr>
|
||||
" Jai search
|
||||
noremap <leader>sm :call Search(g:campo_jai_path, g:campo_custom_search_args, 1)<cr>
|
||||
|
||||
" Case sensitive
|
||||
noremap <leader>ss :call Search(1, g:campo_custom_search_args)<cr>
|
||||
noremap <F3> :call Search(1, g:campo_custom_search_args_2)<cr>
|
||||
noremap <leader>ss :call Search('.', g:campo_custom_search_args)<cr>
|
||||
noremap <F3> :call Search('.', g:campo_custom_search_args)<cr>
|
||||
" Jai module search
|
||||
noremap <leader>ssm :call Search(g:campo_jai_path, g:campo_custom_search_args)<cr>
|
||||
|
||||
" Navigation for the vim-ripgrep search results.
|
||||
" Hit o on a result line to open the file at that line.
|
||||
|
|
Loading…
Reference in New Issue
Block a user