feat(kotlin): add treesit support

This commit is contained in:
Henrik Lissner
2025-05-22 19:50:04 +02:00
parent c5dd2847ff
commit f5a1af4bf6
4 changed files with 23 additions and 3 deletions

View File

@ -13,10 +13,14 @@ This module adds [[https://kotlinlang.org/][Kotlin]] support to Doom Emacs.
- +lsp ::
Enable LSP support for ~kotlin-mode~. Requires [[doom-module::tools lsp]] and a langserver
(supports [[https://github.com/emacs-lsp/lsp-mode][kotlin-language-server]]).
- +tree-sitter ::
Leverages tree-sitter for better syntax highlighting and structural text
editing. Requires Emacs 29.1+ and [[doom-module::tools tree-sitter]].
** Packages
- [[doom-package:flycheck-kotlin]] if [[doom-module::checkers syntax]]
- [[doom-package:kotlin-mode]]
- [[doom-package:kotlin-ts-mode]]
** Hacks
/No hacks documented for this module./

View File

@ -1,11 +1,12 @@
;;; lang/kotlin/config.el -*- lexical-binding: t; -*-
(after! kotlin-mode
(when (modulep! +lsp)
(add-hook 'kotlin-mode-local-vars-hook #'lsp! 'append))
(set-docsets! 'kotlin-mode "Kotlin")
(set-repl-handler! 'kotlin-mode #'kotlin-repl)
(when (modulep! +lsp)
(add-hook 'kotlin-mode-local-vars-hook #'lsp! 'append))
(map! :map kotlin-mode-map
:localleader
:prefix ("b" . "build")
@ -17,3 +18,15 @@
(use-package! flycheck-kotlin
:when (modulep! :checkers syntax -flymake)
:hook (kotlin-mode . flycheck-kotlin-setup))
(use-package! kotlin-ts-mode
:when (modulep! +tree-sitter)
:when (fboundp 'treesit-available-p)
:defer t
:init
(set-tree-sitter! 'kotlin-mode 'kotlin-ts-mode
'((kotlin :url "https://github.com/fwcd/tree-sitter-kotlin")))
:config
(when (modulep! +lsp)
(add-hook 'kotlin-ts-mode-local-vars-hook #'lsp! 'append)))

View File

@ -3,5 +3,9 @@
(package! kotlin-mode :pin "fddd747e5b4736e8b27a147960f369b86179ddff")
(when (and (modulep! +tree-sitter)
(fboundp 'treesit-available-p))
(package! kotlin-ts-mode :pin "a25d56cecac9160ba7c140f982ec16ca7b2fe97f"))
(when (modulep! :checkers syntax -flymake)
(package! flycheck-kotlin :pin "a2a6abb9a7f85c6fb15ce327459ec3c8ff780188"))

View File

@ -32,7 +32,6 @@
(java "https://github.com/tree-sitter/tree-sitter-java" nil nil nil nil)
(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "master" "src" nil nil)
(json "https://github.com/tree-sitter/tree-sitter-json" nil nil nil nil)
(kotlin "https://github.com/fwcd/tree-sitter-kotlin" nil nil nil nil)
(latex "https://github.com/latex-lsp/tree-sitter-latex" nil nil nil nil)
(make "https://github.com/tree-sitter-grammars/tree-sitter-make" nil nil nil nil)
(nix "https://github.com/nix-community/tree-sitter-nix" nil nil nil nil)