aboutsummaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/nvim/init.vim9
-rw-r--r--config/nvim/lua/mytelescopefiles.lua22
2 files changed, 23 insertions, 8 deletions
diff --git a/config/nvim/init.vim b/config/nvim/init.vim
index 491ae47..77e572d 100644
--- a/config/nvim/init.vim
+++ b/config/nvim/init.vim
@@ -136,20 +136,13 @@ let g:UltiSnipsJumpBackwardTrigger='<c-k>'
" Telescope
nnoremap <c-c><c-c> :Telescope buffers<cr>
-nnoremap <c-p> :call TelescopeFiles()<cr>
+nnoremap <c-p> :lua require('mytelescopefiles')()<cr>
nnoremap <c-s-p> :Telescope lsp_document_symbols<cr>
nmap <leader>] :Telescope lsp_definitions<cr>
nmap <leader><leader>] :Telescope lsp_type_definitions<cr>
nmap <leader>[ :Telescope lsp_implementations<cr>
nmap <leader><leader>[ :Telescope lsp_references<cr>
nmap <F9> :Telescope diagnostics bufnr=0<cr>
-function TelescopeFiles()
- if stridx(system('git rev-parse --is-inside-work-tree 2>/dev/null || true'), 'true') != -1
- lua require('telescope.builtin').git_files{use_file_path=true,git_command={"sh","-c","git ls-files -c --recurse-submodules && git ls-files -o --exclude-standard"}}
- else
- lua require('telescope.builtin').find_files{}
- endif
-endfunction
" Copy line location
nmap <leader><leader>c :let @+=expand("%:p") . ":" . line(".")<cr>
diff --git a/config/nvim/lua/mytelescopefiles.lua b/config/nvim/lua/mytelescopefiles.lua
new file mode 100644
index 0000000..46253eb
--- /dev/null
+++ b/config/nvim/lua/mytelescopefiles.lua
@@ -0,0 +1,22 @@
+local ts = require("telescope.builtin")
+local utils = require("telescope.utils")
+
+return function()
+ local root, ret = utils.get_os_command_output({ "git", "rev-parse", "--show-toplevel" }, vim.fn.expand("%:h"))
+ if ret == 0 then
+ ts.git_files({
+ git_command = {
+ "sh",
+ "-c",
+ "git -C "
+ .. root[1]
+ .. " ls-files -c --recurse-submodules && git -C "
+ .. root[1]
+ .. " ls-files -o --exclude-standard",
+ },
+ })
+ else
+ -- TODO use root if this file is relative to the current one
+ ts.find_files()
+ end
+end