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/builtin/internal.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/builtin/internal.lua')
| -rw-r--r-- | lua/telescope/builtin/internal.lua | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/lua/telescope/builtin/internal.lua b/lua/telescope/builtin/internal.lua index 5355d5f..226373b 100644 --- a/lua/telescope/builtin/internal.lua +++ b/lua/telescope/builtin/internal.lua @@ -113,8 +113,22 @@ internal.planets = function(opts) end internal.symbols = function(opts) + local initial_mode = vim.fn.mode() local files = vim.api.nvim_get_runtime_file("data/telescope-sources/*.json", true) - if table.getn(files) == 0 then + local data_path = (function() + if not opts.symbol_path then + return Path:new { vim.fn.stdpath "data", "telescope", "symbols" } + else + return Path:new { opts.symbol_path } + end + end)() + if data_path:exists() then + for _, v in ipairs(require("plenary.scandir").scan_dir(data_path:absolute(), { search_pattern = "%.json$" })) do + table.insert(files, v) + end + end + + if #files == 0 then print( "No sources found! Check out https://github.com/nvim-telescope/telescope-symbols.nvim " .. "for some prebuild symbols or how to create you own symbol source." @@ -157,7 +171,11 @@ internal.symbols = function(opts) }, sorter = conf.generic_sorter(opts), attach_mappings = function(_) - actions.select_default:replace(actions.insert_symbol) + if initial_mode == "i" then + actions.select_default:replace(actions.insert_symbol_i) + else + actions.select_default:replace(actions.insert_symbol) + end return true end, }):find() |
