nvim-gps icon indicating copy to clipboard operation
nvim-gps copied to clipboard

Add more languages

Open ovidius72 opened this issue 3 years ago • 23 comments

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

ovidius72 avatar Aug 22 '21 22:08 ovidius72

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!

SmiteshP avatar Aug 23 '21 01:08 SmiteshP

I would like support for dart

Chaitanyabsprip avatar Aug 24 '21 06:08 Chaitanyabsprip

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

SmiteshP avatar Aug 24 '21 09:08 SmiteshP

@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.

ovidius72 avatar Aug 24 '21 09:08 ovidius72

That would be great!!

SmiteshP avatar Aug 24 '21 09:08 SmiteshP

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

danielebra avatar Aug 27 '21 07:08 danielebra

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 😃

SmiteshP avatar Aug 27 '21 12:08 SmiteshP

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

SmiteshP avatar Aug 27 '21 15:08 SmiteshP

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?

Chaitanyabsprip avatar Aug 27 '21 17:08 Chaitanyabsprip

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.

SmiteshP avatar Aug 27 '21 17:08 SmiteshP

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 avatar Sep 05 '21 12:09 SmiteshP

@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.

ovidius72 avatar Sep 05 '21 15:09 ovidius72

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"
      }
    },

ovidius72 avatar Sep 05 '21 15:09 ovidius72

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

SmiteshP avatar Sep 05 '21 15:09 SmiteshP

I added support for YANG! :tada: https://github.com/SmiteshP/nvim-gps/pull/24

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

Hubro avatar Sep 20 '21 05:09 Hubro

Support for Vue would be highly appreciated.

aMOPel avatar Oct 26 '21 14:10 aMOPel

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

Chaitanyabsprip avatar Dec 22 '21 21:12 Chaitanyabsprip

@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 :)

mo8it avatar Apr 04 '22 00:04 mo8it

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

Suyashtnt avatar Jun 10 '22 19:06 Suyashtnt

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.

SmiteshP avatar Jun 11 '22 11:06 SmiteshP

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)

Suyashtnt avatar Jun 11 '22 11:06 Suyashtnt

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.

SmiteshP avatar Jun 11 '22 11:06 SmiteshP

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

Suyashtnt avatar Jun 11 '22 14:06 Suyashtnt