aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-treesitter.lua
diff options
context:
space:
mode:
authorKristijan Husak <husakkristijan@gmail.com>2020-10-09 19:08:44 +0200
committerKiyan Yazdani <yazdani.kiyan@protonmail.com>2020-10-11 13:35:18 +0200
commit3aa7e575e23228477e16940d2bc786a52a142eb8 (patch)
tree8c850ab3c073e44546645a2d6a396a6265646e41 /lua/nvim-treesitter.lua
parentAdd implementation for improved statusline. Closes #545. (diff)
downloadnvim-treesitter-3aa7e575e23228477e16940d2bc786a52a142eb8.tar
nvim-treesitter-3aa7e575e23228477e16940d2bc786a52a142eb8.tar.gz
nvim-treesitter-3aa7e575e23228477e16940d2bc786a52a142eb8.tar.bz2
nvim-treesitter-3aa7e575e23228477e16940d2bc786a52a142eb8.tar.lz
nvim-treesitter-3aa7e575e23228477e16940d2bc786a52a142eb8.tar.xz
nvim-treesitter-3aa7e575e23228477e16940d2bc786a52a142eb8.tar.zst
nvim-treesitter-3aa7e575e23228477e16940d2bc786a52a142eb8.zip
Remove old statusline implementation with new one.
Diffstat (limited to 'lua/nvim-treesitter.lua')
-rw-r--r--lua/nvim-treesitter.lua31
1 files changed, 4 insertions, 27 deletions
diff --git a/lua/nvim-treesitter.lua b/lua/nvim-treesitter.lua
index b61164268..1eb5276f2 100644
--- a/lua/nvim-treesitter.lua
+++ b/lua/nvim-treesitter.lua
@@ -27,32 +27,6 @@ function M.define_modules(...)
configs.define_modules(...)
end
-function M.statusline(indicator_size)
- if not parsers.has_parser() then return end
- local indicator_size = indicator_size or 100
-
- local current_node = ts_utils.get_node_at_cursor()
- if not current_node then return "" end
-
- local expr = current_node:parent()
- local prefix = ""
- if expr then
- prefix = "->"
- end
-
- local indicator = current_node:type()
- while expr and (#indicator + #(expr:type()) + 5) < indicator_size do
- indicator = expr:type() .. prefix .. indicator
- expr = expr:parent()
- end
-
- if expr then
- return "..." .. indicator
- else
- return indicator
- end
-end
-
local get_line_for_node = function(node, type_patterns, transform_fn)
local node_type = node:type()
local is_valid = false
@@ -74,9 +48,12 @@ local transform_line = function(line)
return line:gsub('[%[%(%{]*%s*$', '')
end
-function M.named_statusline(opts)
+function M.statusline(opts)
if not parsers.has_parser() then return end
local options = opts or {}
+ if type(opts) == 'number' then
+ options = {indicator_size = opts}
+ end
local indicator_size = options.indicator_size or 100
local type_patterns = options.type_patterns or {'class', 'function', 'method'}
local transform_fn = options.transform_fn or transform_line