Skip to content
This repository has been archived by the owner on Jul 5, 2022. It is now read-only.

Add more languages #4

Open
ovidius72 opened this issue Aug 22, 2021 · 23 comments
Open

Add more languages #4

ovidius72 opened this issue Aug 22, 2021 · 23 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@ovidius72
Copy link

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

@SmiteshP
Copy link
Owner

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 SmiteshP added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Aug 23, 2021
@Chaitanyabsprip
Copy link

I would like support for dart

@SmiteshP
Copy link
Owner

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

@ovidius72
Copy link
Author

ovidius72 commented Aug 24, 2021

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

@SmiteshP
Copy link
Owner

That would be great!!

@danielebra
Copy link

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

@SmiteshP
Copy link
Owner

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
Copy link
Owner

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

@Chaitanyabsprip
Copy link

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?

@SmiteshP
Copy link
Owner

SmiteshP commented Aug 27, 2021

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 SmiteshP pinned this issue Aug 30, 2021
@SmiteshP
Copy link
Owner

SmiteshP commented Sep 5, 2021

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! 😃

@ovidius72
Copy link
Author

ovidius72 commented Sep 5, 2021

@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
Copy link
Author

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

@SmiteshP
Copy link
Owner

SmiteshP commented Sep 5, 2021

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

@Hubro
Copy link
Contributor

Hubro commented Sep 20, 2021

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

@aMOPel
Copy link

aMOPel commented Oct 26, 2021

Support for Vue would be highly appreciated.

@Chaitanyabsprip
Copy link

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
Copy link

mo8it commented Apr 4, 2022

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

@Suyashtnt
Copy link

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

@SmiteshP
Copy link
Owner

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.

@Suyashtnt
Copy link

Suyashtnt commented Jun 11, 2022

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)

@SmiteshP
Copy link
Owner

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.

@Suyashtnt
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

8 participants