diff options
| author | Simon Hauser <Simon-Hauser@outlook.de> | 2021-08-21 16:48:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-21 16:48:19 +0200 |
| commit | 364d795d22e7a080be793379e30cfdd2036840cf (patch) | |
| tree | 05ea225d8a08374347d61f42d8ce36704e34c1d0 /lua/telescope/actions/init.lua | |
| parent | 81ab591180e22150b00d464008c4cd82c3e8d86d (diff) | |
fix: some improvements for telescope.symbols if run in insert mode (#1117)
- keep insert if run in insert mode
- also look in `.local/share/nvim/telescope/symbols/*.json` for symbols
can be overriden with `symbol_path`
Diffstat (limited to 'lua/telescope/actions/init.lua')
| -rw-r--r-- | lua/telescope/actions/init.lua | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lua/telescope/actions/init.lua b/lua/telescope/actions/init.lua index 43315cc..7f82823 100644 --- a/lua/telescope/actions/init.lua +++ b/lua/telescope/actions/init.lua @@ -373,9 +373,19 @@ actions.run_builtin = function(prompt_bufnr) end actions.insert_symbol = function(prompt_bufnr) - local selection = action_state.get_selected_entry() + local symbol = action_state.get_selected_entry().value[1] actions.close(prompt_bufnr) - vim.api.nvim_put({ selection.value[1] }, "", true, true) + vim.api.nvim_put({ symbol }, "", true, true) +end + +actions.insert_symbol_i = function(prompt_bufnr) + local symbol = action_state.get_selected_entry().value[1] + actions._close(prompt_bufnr, true) + local cursor = vim.api.nvim_win_get_cursor(0) + vim.api.nvim_buf_set_text(0, cursor[1] - 1, cursor[2], cursor[1] - 1, cursor[2], { symbol }) + vim.schedule(function() + vim.api.nvim_win_set_cursor(0, { cursor[1], cursor[2] + #symbol }) + end) end -- TODO: Think about how to do this. |
