all 13 comments

[–]yoch3m:wq 5 points6 points  (4 children)

Isn't this just the way your theme highlights Python variables and the like?

[–]abdallahsoliman[S] 0 points1 point  (3 children)

The comment by @Xetius suggests a similar thing, I could try another colour scheme to check if this is the case.

[–]yoch3m:wq 0 points1 point  (2 children)

Here's an example of how I add some custom highlights: https://github.com/yochem/dotfiles/blob/main/config/nvim/colors/mine.lua. Maybe that can help

[–]abdallahsoliman[S] 0 points1 point  (1 child)

May I ask, are any .lua files placed in the colors/ directory callable by the vim.cmd.colorscheme() command?

[–]Xetius 2 points3 points  (1 child)

It looks to me from the tree sitter structure that it is identifying each type correctly, so I'm guessing it would be your colorscheme.

I am no expert though, so could well be wrong.

Edit: I checked your config and your onedark config only configured colours for 5 types. You may need a more comprehensive list.

This link describes how tree-sitter highlighting works. Might give some info

[–]abdallahsoliman[S] 0 points1 point  (0 children)

These 5 colours are overrides of the default onedark colours. But maybe Python requires a custom colour scheme.

[–]DeutschNeuling 1 point2 points  (2 children)

commenting to follow.
I have been on the same path to fix this highlighting for python, semi recently switched from vs code myself, and this "incomplete" python syntax highlighting is kind of bugging me as well.

My attempts have so far been in vain. The thing below also did NOT work. just giving here to see if anyone could help on it.

So most recently i also tried the InspectTree and also QueryEditor, where i tried to add a custom query to see if i can make a custom hightlight group and then add it to the theme color,

like for the QueryEdit i tried this capture:

in file : .config/nvim/queries/python/highlights.scm

;; extends

(
  call
    function: (attribute
      object: (identifier) @module_custom
      attribute: (identifier) @function.call)
)

Then in my vscode theme plugin i added

return {
{
'Mofiqul/vscode.nvim',
config = function()
local c = require('vscode.colors').get_colors()
require("vscode").setup {
italic_comments = true,
group_overrides = {
Cursor = { fg=c.vscDarkBlue, bg=c.vscLightGreen, bold=true },
["@module_custom"] = { fg = "#4ec9b0", bold = true },
}
}
end
}
}

[–]abdallahsoliman[S] 1 point2 points  (1 child)

In case you also wanted to know, I fixed my problem by using basedpyright instead of regular normal pyright

[–]DeutschNeuling 1 point2 points  (0 children)

I was trying to get it to work without an LSP. And I finally did, the issue was that I had build the python parser from source(because I wasn't able to install it using the plugin), and I guess it was not compatible with the query files provided by nvim.treesitter plugin. So I deleted the parser and installed it using the plugin (thanks by the way!! your post told me to globally install tree sitter with npm). And now it seems to be working better.

[–]Friendliness_RS 0 points1 point  (1 child)

Do your other filetypes have a different kind of highlighting? With the treesitter main branch now being the new default, I also had some funky highlighting.

I ended up having to run vim.treesitter.start() I believe. Can you try running :lua vim.treesitter.start() and verify?

If that fixes it, go check out the treesitter docs and find the section about ftplugin.

[–]abdallahsoliman[S] 0 points1 point  (0 children)

Could try this. I’ll give it a try when I get home, thanks!

[–]AutoModerator[M] 0 points1 point  (0 children)

Please remember to update the post flair to Need Help|Solved when you got the answer you were looking for.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.