Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work in another languages than english #4

Closed
gbprod opened this issue Oct 19, 2022 · 2 comments
Closed

Does not work in another languages than english #4

gbprod opened this issue Oct 19, 2022 · 2 comments

Comments

@gbprod
Copy link

gbprod commented Oct 19, 2022

Hi!
I'm trying to make this parser works in Neovim but I'm having an issue because I'm using git in french :/
Your parser seems to look for english text and does not works and does not works...

I think it's not a good idea to include all possible translations into this parser but maybe there is another way to do that ?

Eg:

Introduce git-commit parser

This commit...

# Veuillez saisir le message de validation pour vos modifications. Les lignes
# commençant par '#' seront ignorées, et un message vide abandonne la validation.
#
# Sur la branche main
# Votre branche est à jour avec 'origin/main'.
#
# Modifications qui seront validées :
#	modifié :         lua/usr/treesitter.lua
#
# ------------------------ >8 ------------------------
# Ne touchez pas à la ligne ci-dessus.
# Tout ce qui suit sera éliminé.
diff --git a/lua/usr/treesitter.lua b/lua/usr/treesitter.lua
index 2962f73..04abaab 100644
--- a/lua/usr/treesitter.lua
+++ b/lua/usr/treesitter.lua
@@ -9,6 +9,16 @@ function treesitter.plugins(use)
   use("nvim-treesitter/playground")
   use("JoosepAlviste/nvim-ts-context-commentstring")
   use("windwp/nvim-ts-autotag")
+  local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
+  parser_config.git_commit = {
+    install_info = {
+      url = "https://github.com/the-mikedavis/tree-sitter-git-commit",
+      files = { "src/parser.c" },
+      branch = "main",
+    },
+    filetype = "gitcommit",
+  }
 end
 
 function treesitter.setup()
@@ -33,6 +43,7 @@ function treesitter.setup()
       "markdown",
       "diff",
       "bash",
+      "gitcommit",
     },
     textobjects = {
       select = {

I'll try something but I'd like to have your advice on what you think it should be done ?
Thanks

@the-mikedavis
Copy link
Owner

Oh hmm, this may be tough to handle nicely. I think the cleanest way to support it would be to have per-language forks that replace the hard-coded English words with the appropriate translation. That way the queries could be re-used between each language fork and the grammar wouldn't need to become larger and more complex.

@gbprod
Copy link
Author

gbprod commented Oct 20, 2022

Thanks for your feedback, maybe I'll work on a parser more "generic".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants