diff options
Diffstat (limited to 'src/blog/nvim-ts/get-cursor.diff.gsp')
-rw-r--r-- | src/blog/nvim-ts/get-cursor.diff.gsp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/blog/nvim-ts/get-cursor.diff.gsp b/src/blog/nvim-ts/get-cursor.diff.gsp new file mode 100644 index 0000000..6e8f759 --- /dev/null +++ b/src/blog/nvim-ts/get-cursor.diff.gsp @@ -0,0 +1,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, |