aboutsummaryrefslogtreecommitdiff
path: root/lua/plugins/textobject-lexer.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/plugins/textobject-lexer.lua')
-rw-r--r--lua/plugins/textobject-lexer.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/lua/plugins/textobject-lexer.lua b/lua/plugins/textobject-lexer.lua
index 2f9d757..eba65e2 100644
--- a/lua/plugins/textobject-lexer.lua
+++ b/lua/plugins/textobject-lexer.lua
@@ -8,13 +8,17 @@ vis:textobject_new("ii", function(win, pos)
return nil
end
+ local lexer = vis.lexers.load(win.syntax, nil, true)
+ if not lexer then
+ return nil
+ end
+
local before, after = pos - MAX_CONTEXT, pos + MAX_CONTEXT
if before < 0 then
before = 0
end
-- TODO make sure we start at a line boundary?
- local lexer = vis.lexers.load(win.syntax, nil, true)
local data = win.file:content(before, after - before)
local tokens = lexer:lex(data)
local cur = before