2024-04-05 22:56:00 +02:00
|
|
|
(local (mztenv configs parsers ts-utils)
|
|
|
|
(values (require :mzte_nv)
|
|
|
|
(require :nvim-treesitter.configs)
|
2023-02-21 23:11:04 +01:00
|
|
|
(require :nvim-treesitter.parsers)
|
|
|
|
(require :nvim-treesitter.ts_utils)))
|
2023-02-19 21:23:55 +01:00
|
|
|
|
2024-04-05 22:56:00 +02:00
|
|
|
;; Nix based parsers
|
|
|
|
(let [path mztenv.reg.tree_sitter_parsers]
|
|
|
|
(when path
|
|
|
|
(vim.opt.runtimepath:append path)))
|
|
|
|
|
2023-02-19 21:23:55 +01:00
|
|
|
(var parser-config (parsers.get_parser_configs))
|
|
|
|
|
|
|
|
(tset parser-config :haxe {:install_info {:url "https://github.com/vantreeseba/tree-sitter-haxe"
|
|
|
|
:files [:src/parser.c]
|
|
|
|
:branch :main}
|
|
|
|
:filetype :haxe})
|
|
|
|
|
|
|
|
(configs.setup {:highlight {:enable true}
|
|
|
|
:autotag {:enable true}
|
|
|
|
:indent {:enable true}
|
2023-02-21 22:44:36 +01:00
|
|
|
:playground {:enable true}
|
|
|
|
:incremental_selection {:enable true
|
|
|
|
:keymaps {:init_selection :fv
|
|
|
|
:node_incremental :v
|
|
|
|
:node_decremental :V
|
|
|
|
:scope_incremental false}}})
|
2023-02-21 23:11:04 +01:00
|
|
|
|
|
|
|
(fn delete-node-under-cursor []
|
|
|
|
(local (r1 c1 r2 c2)
|
|
|
|
(vim.treesitter.get_node_range (ts-utils.get_node_at_cursor)))
|
|
|
|
(vim.api.nvim_buf_set_text 0 r1 c1 r2 c2 []))
|
|
|
|
|
2023-03-07 18:24:39 +01:00
|
|
|
(let [mopt (. (require :mzte_nv) :utils :map_opt)]
|
|
|
|
;; Shorthand for deleting the TS node under the cursor
|
|
|
|
(vim.keymap.set :n :D delete-node-under-cursor mopt)
|
|
|
|
;; Shorthand for deleting the TS node under the cursor and switching to insert mode
|
|
|
|
(vim.keymap.set :n :C
|
|
|
|
(fn [] (delete-node-under-cursor) (vim.cmd.startinsert)) mopt))
|