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

No syntax highlighting for the http file #30

Closed
ashishbinu opened this issue Jul 19, 2021 · 13 comments · Fixed by #264
Closed

No syntax highlighting for the http file #30

ashishbinu opened this issue Jul 19, 2021 · 13 comments · Fixed by #264

Comments

@ashishbinu
Copy link

First of all thanks for this amazing plugin.

I was trying out this plugin but the http file is not getting syntax highlighted as shown in the image in readme. The response is getting highlighted correctly.
image

@NTBBloodbath
Copy link
Member

Hey, thank you for using it!

Have you tried using other colorscheme? Maybe yours is missing some highlighting groups.

Regards

@ashishbinu
Copy link
Author

@NTBBloodbath I have a file with lot highlighting groups defined with different colors. When I don't source that file in init.lua the http file gets syntax highlighting. Is there a better I can solve this issue without removing my highlighting file from init.lua.

@NTBBloodbath
Copy link
Member

Hmm that's weird, aren't you clearing some colors? Try opening a http file and then running :syntax on.

Also, are you lazy-loading rest.nvim?

I was doing some tests for a Treesitter parser for the http files to ditch these syntax/ files, but it's not usable yet.

@ashishbinu
Copy link
Author

@NTBBloodbath I tried reinstalling rest.nvim using packer again. I added the below code into packer config.

use {
    "NTBBloodbath/rest.nvim",
    requires = { "nvim-lua/plenary.nvim" },
    config = function()
        require('rest-nvim').setup()
    end
}        

Error after doing :PackerCompile is shown below:

output.mp4

image

Then, when I add the ft = "http" in the rest.nvim packer config the :PackerCompile doesn't give any errors.

use {
    "NTBBloodbath/rest.nvim",
    ft = "http",
    requires = { "nvim-lua/plenary.nvim" },
    config = function()
        require('rest-nvim').setup()
    end
}
output.mp4

So , after installing rest.nvim by putting ft = "http" in packer config.
When I open http file now. It doesn't show syntax highlighing. There is also no filetype set for it. After doing setl ft=http it gives syntax highlighting. I have attached video below for this issue:

output.mp4

@ashishbinu
Copy link
Author

ashishbinu commented Jul 21, 2021

For now I have added an autocmd to set filetype to httpand it gives syntax highlighting.

vim.api.nvim_exec([[
  augroup HttpFiletype
    autocmd!
    autocmd BufNewFile,BufRead *.http set ft=http
  augroup end
]],false)

Now the syntax highlighting works even if I lazy load plugin with ft=http or without lazyloading.

@mr-majkel
Copy link
Contributor

mr-majkel commented Jul 21, 2021

@NTBBloodbath I can confirm this issue. The issue is there since moving to setup() approach - there is no event listening to fire
it automatically on http files, and the function is operating only on the current buffer. I think it was working ok with the ftdetect approach.

@ashishbinu if you comment the augroup section, restart nvim, go to the http buffer and type

:lua require('rest-nvim').setup()

this should give the proper highlighting.

@ashishbinu
Copy link
Author

@ashishbinu if you comment the augroup section, restart nvim, go to the http buffer and type

:lua require('rest-nvim').setup()

this should give the proper highlighting.

Yes, running the above command enables the syntax highlighting.

@NTBBloodbath
Copy link
Member

Hey, can you try lazy-loading rest.nvim with the BufWinEnter event? That's my current setup for it and it's working fine. However I'll dig on it later without lazy-loading it ( I'll not be at home :( ).

	use({
		'NTBBloodbath/rest.nvim',
		requires = 'nvim-lua/plenary.nvim',
		config = function()
			require('rest-nvim').setup()
		end,
		event = 'BufEnter',
	})

@ashishbinu
Copy link
Author

Hey, can you try lazy-loading rest.nvim with the BufWinEnter event? That's my current setup for it and it's working fine. However I'll dig on it later without lazy-loading it ( I'll not be at home :( ).

	use({
		'NTBBloodbath/rest.nvim',
		requires = 'nvim-lua/plenary.nvim',
		config = function()
			require('rest-nvim').setup()
		end,
		event = 'BufEnter',
	})

I tried this lazy loading in my config...but it didn't make a difference it only syntax highlighting when I opened file like nvim api.http but when I tried doing by first opening nvim and then navigating syntax highlighting didn't work. This was the same case without lazy loading also.

@NTBBloodbath
Copy link
Member

Hmm that's some weird stuff. I'll leave it opened while I develop the http treesitter parser so we can revert the setup stuff and use a ftdetect file again

@NTBBloodbath
Copy link
Member

NTBBloodbath commented Aug 15, 2021

Hey, I was finally able to start with the tree-sitter parser. Still a lot of stuff to be done but hopefully it should be ready for daily usage in a few days, here's the current progress

imagen

Also here is the repository with the actual work if someone has knowledge parsing stuff, regex and tree-sitter and wants to help

@NTBBloodbath
Copy link
Member

Just showing the progress btw, the only thing left is the JSON stuff ig

imagen

@NTBBloodbath
Copy link
Member

Hey, so after a while we are ready to go with the treesitter parser. I'll add instructions for using it (it seems that I'll need to send a PR to nvim-treesitter or something like that for adding it to be able to install it by using TSInstall without extra setup) and get rid of that weird lazy-loading :p

Screenshot_20210826_102052

jens1205 pushed a commit to jens1205/rest.nvim that referenced this issue Aug 28, 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

Successfully merging a pull request may close this issue.

3 participants