From ea77956c0224d9f9997d60e91642a4e255750f5b Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 14 Nov 2023 18:10:22 +0100 Subject: Add a new blog post --- src/blog/nvim-ts/get-cursor.diff.gsp | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/blog/nvim-ts/get-cursor.diff.gsp (limited to 'src/blog/nvim-ts/get-cursor.diff.gsp') 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, -- cgit v1.2.3