SmiteshP/nvim-gps

Add more languages

Opened this issue ยท 23 comments

Very nice plugin. Are you planning to add more languages?.
I'd like to see typescript ad typescript react (.tsx)

Hey! I am willing to add more languages to the list :)
To begin with I stuck to languages I am proficient in and/or have some knowledge about the language. Please feel free to make a PR for your favorite languages.
I will soon add a contributions section to readme to explain how the tree-sitter queries work!

I would like support for dart

Hey @ovidius72! I just added some basic queries for typescript.

@SmiteshP Thank you.
The next weekend I would like to have a look at the Treesitter APIs and see if I can help in some way.

That would be great!!

Hey @ovidius72! I just added some basic queries for typescript.

Hey @SmiteshP , do those changes also apply for typescriptreact file? Would love to also have the gps features with that file type

Hey @SmiteshP , do those changes also apply for typescriptreact file? Would love to also have the gps features with that file type

Not right now, I actually don't know a lot about typescript and typescript-react ๐Ÿ˜…
Are they very similar? If so we may be able to just copy the typescript queries for typescript-react and then get it to work. If there are some differences, I would encourage you to try and contribute queries for it ๐Ÿ˜ƒ

Hey @Chaitanyabsprip! After looking into it, unfortunately I don't think it will be possible to support dart in this plugin. Because unlike other languages, the treesitter for dart creates function signature and function body as sibling nodes. So there will be no single node that can be captured as scope-root. Until this behavior changes its impossible to write queries for this :(
This issue here discusses this behavior UserNobody14/tree-sitter-dart#12

I don't see why that would be needed to be different for a language like dart, just query the body and ignore the signature? I have no experience writing scheme but this sounds logical to me.
I would like to make a PR regarding this, can you please point me to some resources that I can use to get started with this?

can you please point me to some resources that I can use to get started with this?

You can look at the contributions.md file in the repo. I have roughly explained how the plugins algorithm works and also linked the tree-sitter website that explains the query syntax.

just query the body and ignore the signature?

Once you understand how nvim-gps is extracting information from treesitter, hopefully you will understand why this is impossible to do for dart. When the cursor will reside inside the function body we will not encounter the function signature on the way to the root node. And the information about the function name is contained in the function signature.

Hello @ovidius72 and @danielebra, I recently added support for jsx and tsx files too! As far as I understand they are pretty similar to javascript and typescript respectively so the same treesitter queries should work with them too.
And thanks to @Lazytangent's contributions, the queries for javascript and typescript have improved! ๐Ÿ˜ƒ

@SmiteshP Thank you. I'm sorry I didn't have the time to check it out.
I'm just playing with it right now. I configured it with lualine as for you example.
In tsx files it show the number "1" in place of methods.
In .ts file it shows nothing for me.
Notification_Center

typescript file. Inside an arrow function.
Notification_Center

the result of lua print(require('nvim-gps').is_available() give me nil

In typescriptreact it would be great to detect also JSX tags.
And in typescript I would add the type idetifier.

Thanks.

Here is the lualine section where i show up the gps module info.

  sections = {
    lualine_a = {{'mode', format=function(mode) return mode:sub(1,1) end }},
    lualine_b = {
      {'filename', { file_status = true, path = 1  }}
    },
    lualine_c = {
      {
        'diagnostics',
        sources = { 'coc' },
        -- displays diagnostics from defined severity
        sections = {'error', 'warn', 'info', 'hint'},
        -- all colors are in format #rrggbb
        color_error = '#eb6f92', -- changes diagnostic's error foreground color
        color_warn = '#f6c177', -- changes diagnostic's warn foreground color
        color_hint = '#9ccfd8', -- Changes diagnostic's info foreground color
        color_info = '#31748f', -- Changes diagnostic's hint foreground color
        symbols = { error = '๏— ', warn = '๏ฑ ', info = '๏Ÿผ ', hint = '๏ƒซ '}
      },
      { gps.get_location, condition = gps.is_available },
      {
        "g:coc_status"
      }
    },

Hey @ovidius72, could you open a new issue regarding this and share some code snippets so that I can reproduce this error.

Hubro commented

I added support for YANG! ๐ŸŽ‰ #24

Although I suspect I am the only person in the world who uses neovim + nvim-gps and codes in YANG...

Support for Vue would be highly appreciated.

Hey @Chaitanyabsprip! After looking into it, unfortunately I don't think it will be possible to support dart in this plugin. Because unlike other languages, the treesitter for dart creates function signature and function body as sibling nodes. So there will be no single node that can be captured as scope-root. Until this behavior changes its impossible to write queries for this :( This issue here discusses this behavior UserNobody14/tree-sitter-dart#12

Hey, I just came across the FlutterOutline Command in the flutter-tools by akinsho. you could look into that how he's implemented that to add support for dart in your plugin

mo8it commented

@SmiteshP Thank you for this awesome package!

Is it possible to add support for Julia?

I did take a look at how to add a language, but it is not that intuitive.

Thanks :)

Thanks for this package, but would it be possible to add svelte? It's html with some minor extra syntax

Hey @Chaitanyabsprip @mo8it and @Suyashtnt !
Could you checkout my other plugin https://github.com/SmiteshP/nvim-navic ?
It is similar to nvim-gps but makes use of LSP instead of treesitter. So it won't need any special attention for every language, it will work as long as there is a language server for that language.

Hey @Chaitanyabsprip @mo8it and @Suyashtnt !

Could you checkout my other plugin https://github.com/SmiteshP/nvim-navic ?

It is similar to nvim-gps but makes use of LSP instead of treesitter. So it won't need any special attention for every language, it will work as long as there is a language server for that language.

Is there a way to integrate this into something like winbar.nvim? (Plugin that uses nvim-gps for showing a vscode-like winbar)

Yep! If you are using feline.nvim just add the component to feline's winbar setup function. Or you can also use the native neovim way.

Yep! If you are using feline.nvim just add the component to feline's winbar setup function. Or you can also use the native neovim way.

I'm talking about the plugin called winbar.nvim, is there a way to use this in a way that resembles it's look