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 g:campo_ctags_exclude = g:campo_ctags_exclude + ['.git', 'node_modules']
 | 
				
			||||||
    let l:exclude_list = ""
 | 
					    let l:exclude_list = ""
 | 
				
			||||||
    for name in g:campo_ctags_exclude
 | 
					    for name in g:campo_ctags_exclude
 | 
				
			||||||
        let l:exclude_list = l:exclude_list . "--exclude=" . name . " "
 | 
					        let l:exclude_list .= "--exclude=" . name . " "
 | 
				
			||||||
    endfor
 | 
					    endfor
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    " Include local variables for C-like languages.
 | 
					    " 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.
 | 
					    " 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$\)')
 | 
					    let l:recursive = matchstr(g:campo_custom_ctags_args, '\(-R\s\)\|\(-R$\)\|\(--recurse=yes\)\|\(--recurse\s\)\|\(--recurse$\)')
 | 
				
			||||||
    if l:recursive == ''
 | 
					    if l:recursive == ''
 | 
				
			||||||
        let l:ctags_cmd = l:ctags_cmd . ' ' . expand('%:t')
 | 
					        let l:ctags_cmd .= ' ' . expand('%:t')
 | 
				
			||||||
        echo "Creating non-recursive ctags"
 | 
					        echo "Creating non-recursive ctags"
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        echo "Creating recursive ctags"
 | 
					        echo "Creating recursive ctags"
 | 
				
			||||||
| 
						 | 
					@ -910,7 +910,7 @@ let g:rg_window_height = g:quickfix_pane_height
 | 
				
			||||||
function! g:SetExtraCtagsPaths(paths_array)
 | 
					function! g:SetExtraCtagsPaths(paths_array)
 | 
				
			||||||
    let l:list = './tags,tags' " This is the default tags list set by vim.
 | 
					    let l:list = './tags,tags' " This is the default tags list set by vim.
 | 
				
			||||||
    for path in a:paths_array
 | 
					    for path in a:paths_array
 | 
				
			||||||
        let l:list = l:list . ',' . path
 | 
					        let l:list .= ',' . path
 | 
				
			||||||
    endfor
 | 
					    endfor
 | 
				
			||||||
    let &tags=l:list
 | 
					    let &tags=l:list
 | 
				
			||||||
endfunction
 | 
					endfunction
 | 
				
			||||||
| 
						 | 
					@ -955,7 +955,7 @@ function! CtrlP_JaiSearch(jai_rel_search_path)
 | 
				
			||||||
    endif
 | 
					    endif
 | 
				
			||||||
    let l:path = g:campo_jai_path
 | 
					    let l:path = g:campo_jai_path
 | 
				
			||||||
    if a:jai_rel_search_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
 | 
					    endif
 | 
				
			||||||
    if !isdirectory(l:path)
 | 
					    if !isdirectory(l:path)
 | 
				
			||||||
        call PrintError("Directory ".l:path." doesn't exist.")
 | 
					        call PrintError("Directory ".l:path." doesn't exist.")
 | 
				
			||||||
| 
						 | 
					@ -1306,12 +1306,19 @@ function! StopRunTask()
 | 
				
			||||||
endfunction
 | 
					endfunction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function! Build(optimized=0)
 | 
					function! Build(optimized=0)
 | 
				
			||||||
    let l:params = ''
 | 
					    let l:params = ""
 | 
				
			||||||
    if tolower(expand('%:e')) == "jai"
 | 
					    let l:ext = tolower(expand('%:e'))
 | 
				
			||||||
 | 
					    if l:ext == "jai"
 | 
				
			||||||
 | 
					        " Jai build
 | 
				
			||||||
 | 
					        let l:cmd = "jai % "
 | 
				
			||||||
        if a:optimized == 1
 | 
					        if a:optimized == 1
 | 
				
			||||||
            let l:params .= '-release '
 | 
					            let l:cmd .= "-release "
 | 
				
			||||||
        endif
 | 
					        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
 | 
					    else
 | 
				
			||||||
        if a:optimized == 1
 | 
					        if a:optimized == 1
 | 
				
			||||||
            let l:params .= '-o '
 | 
					            let l:params .= '-o '
 | 
				
			||||||
| 
						 | 
					@ -1385,8 +1392,8 @@ nnoremap <C-p> :cp<CR>
 | 
				
			||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 | 
					"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" Search using ripgrep (first install with Rust: cargo install ripgrep).
 | 
					" Search using ripgrep (first install with Rust: cargo install ripgrep).
 | 
				
			||||||
function! Search(case_sensitive, search_args)
 | 
					function! Search(path, search_args, case_insensitive=0)
 | 
				
			||||||
    let l:helper = "Search [" . a:search_args . " | " . (a:case_sensitive ? "case-sensitive" : "case-insensitive") . "]: "
 | 
					    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)
 | 
					    let l:term = input(l:helper)
 | 
				
			||||||
    if empty(l:term)
 | 
					    if empty(l:term)
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
| 
						 | 
					@ -1396,20 +1403,24 @@ function! Search(case_sensitive, search_args)
 | 
				
			||||||
    "quickfix window doesn't seem to parse the ansi color codes.
 | 
					    "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
 | 
					    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"
 | 
					        let l:rg_args .= " --ignore-case"
 | 
				
			||||||
    endif
 | 
					    endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    exec 'Rg ' . l:rg_args . ' -e "' . l:term . '"'
 | 
					    exec 'Rg ' . l:rg_args . ' -e "' . l:term . '"' . ' ' . a:path
 | 
				
			||||||
endfunction
 | 
					endfunction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" Case insensitive
 | 
					" Case insensitive
 | 
				
			||||||
noremap <leader>s :call Search(0, g:campo_custom_search_args)<cr>
 | 
					noremap <leader>s  :call Search('.', g:campo_custom_search_args, 1)<cr>
 | 
				
			||||||
noremap <F2> :call Search(0, g:campo_custom_search_args_2)<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
 | 
					" Case sensitive
 | 
				
			||||||
noremap <leader>ss :call Search(1, g:campo_custom_search_args)<cr>
 | 
					noremap <leader>ss  :call Search('.', g:campo_custom_search_args)<cr>
 | 
				
			||||||
noremap <F3> :call Search(1, g:campo_custom_search_args_2)<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.
 | 
					" Navigation for the vim-ripgrep search results.
 | 
				
			||||||
" Hit o on a result line to open the file at that line.
 | 
					" Hit o on a result line to open the file at that line.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user