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

Fish parser isn't being automatically enable on .fish files #6

Closed
poperigby opened this issue Jul 7, 2021 · 11 comments
Closed

Fish parser isn't being automatically enable on .fish files #6

poperigby opened this issue Jul 7, 2021 · 11 comments

Comments

@poperigby
Copy link

When I open a .fish file, the fish parser isn't automatically enabled. It's automatically enabled for all other file types, and I can set it manually with :set filetype=fish.

@ram02z
Copy link
Owner

ram02z commented Jul 7, 2021

@poperigby Create a file called fish.vim in your config under the ftdetect directory containing au! BufRead,BufNewFile *.fish set filetype=fish. Alternatively you can add that same autocommand to your init.vim

@poperigby
Copy link
Author

Oh, is there a reason that isn't mentioned in the setup guide? Seems a little bit strange it doesn't work out of the box.

@ram02z
Copy link
Owner

ram02z commented Jul 7, 2021

The reason most filetypes 'work out of the box' is that vim sources $VIMRUNTIME/filetype.vim which has autocommands that are used to detect the filetype based on the file extension. .fish unforunately isn't one of them, so we have to create our own autocommand.

@poperigby
Copy link
Author

Oh I see. That probably should be in the setup guide then. Would it just take NeoVim adding fish to that file for it to work correctly?

@ram02z
Copy link
Owner

ram02z commented Jul 8, 2021

Would it just take NeoVim adding fish to that file for it to work correctly?

Yes. Relavant issue for vim vim/vim#820.

Also there is a MR nvim-treesitter/nvim-treesitter#1533 that will give information on filetype detection.

@poperigby
Copy link
Author

Thanks. Should there also be an issue for nvim?

@ahelwer
Copy link

ahelwer commented Jul 9, 2021

@poperigby I am also interested in the answer to this question, seems like nvim-treesitter itself could/should contain Vimscript files in its ftdetect runtime directory for all the languages it supports, similar to its queries?

@ghost
Copy link

ghost commented Jul 9, 2021

I think filetype detection should be done via plugin or configuration. Otherwise it would be a double effort on the nvim-treesitter side.
As an example https://github.com/dag/vim-fish contains configuration for most of the features needed to support fish.
Alternatively, a support for fish could be added directly to vim/nvim so that at least filetype option is set correctly out of the box.

@ahelwer
Copy link

ahelwer commented Jul 9, 2021

@krnik the user experience would be much improved if all users had to do to get the benefits of a tree-sitter grammar for a language were to run :TSInstall lang instead of also having to muck around with filetype identification. The nvim-treesitter project already stores query files for all the languages it supports, and even includes ftdetect files for a couple of its languages. Adding a ftdetect file containing the line au! BufRead,BufNewFile *.fish set filetype=fish (and for any other grammar neovim doesn't identify by default) to nvim-treesitter is a very small amount of effort/space relative to the improved convenience for users, imo.

People are writing tree-sitter grammars for ever-more-obscure languages, many of which are not detected by neovim by default - I have my own motivations here, writing such a grammar for TLA+. When it is finished and I integrate it with nvim-treesitter, I want to tell people all they have to do to use it is run :TSInstall tlaplus instead of also getting them to read a man page of filetype identification with vimscript and mucking about in their config. I guess people can add ftdetect files to nvim-treesitter for their grammar if they want, or not if they don't want.

@ghost
Copy link

ghost commented Jul 9, 2021

Good point about the user experience 👍 I completely agree.

@ram02z
Copy link
Owner

ram02z commented Jul 29, 2021

Detection of fish files will be merged into nvim-treesitter with this PR nvim-treesitter/nvim-treesitter#1635

@ram02z ram02z closed this as completed Jul 31, 2021
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

3 participants