summaryrefslogtreecommitdiffhomepage
path: root/src/blog/nvim-ts/get-cursor.diff.gsp
blob: 6e8f759ea372b9a35cf875e250e4ce75651823c4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
@span .diff-ins {-+local ts_utils = require('nvim-treesitter.ts_utils')}
@span .diff-ins {-+}
 local function map(lhs, rhs)
 	vim.keymap.set('n', lhs, function()
@span .diff-del {--		-- TODO}
@span .diff-ins {-+		local node = ts_utils.get_node_at_cursor()}
@span .diff-ins {-+		if node == nil then}
@span .diff-ins {-+			error('No Tree-Sitter parser found.')}
@span .diff-ins {-+		end}
 	end, {
 		buffer = true,
 		noremap = true,