LiadOz / nvim-dap-repl-highlights

Add syntax highlighting to the nvim-dap REPL
121 stars 6 forks source link

No highlights applied - Please help debugging #9

Closed weilbith closed 1 year ago

weilbith commented 1 year ago

Hey 👋🏾

I think the idea of the plugin is great and I would love to use it. Unfortunately I'm unable to make it work. 🙈

So if I run :TSInstallInfo, I can see dap_repl as installed. If I run :lua =vim.treesitter.inspect_language('dap_repl'), I get the following output:

{
  _abi_version = 14,
  fields = {},
  symbols = { { "\n", false },
    [3] = { "prompt_tag", true },
    [4] = { "continue_prompt_tag", true },
    [5] = { "source_file", true },
    [6] = { "entry", true },
    [7] = { "prompt", true },
    [8] = { "user_input", true },
    [10] = { "user_input_statement", true },
    [11] = { "user_input_content", true },
    [12] = { "output", true },
    [13] = { "output_content", true }
  }
}

Anyhow, if I start a debugging session and have the dap-repl buffer opened, I don't get any highlighting. How can I investigate further why the highlights don't apply? I'm using a Rust project with codelldb.

Thank you very much! 🙏🏾

LiadOz commented 1 year ago

Hi, Have you tried using the setup_highlights function detailed in the README? this manually triggers the highlights for the selected language. If that function works, it is likely the issue is in your configuration

weilbith commented 1 year ago

Hmm. So I run this, but it doesn't change anything. Though, by now I'm a little confused about the dap-repl. So if I type p foo + 1 > 0 I don't get any highlights. But I can't call functions for example like p myList.len(). Maybe I should try it with some other languages and debuggers. Do you use it with Rust?

Edit: I figured I can use ?/nat ... to run native (~> /nat) Rust expressions.

weilbith commented 1 year ago

Closing because I lack in knowledge.

weilbith commented 1 year ago

I tried it now with Python because it has full proper REPL support. But still not working. Am confused.

LiadOz commented 1 year ago

Can you give the output of the :version command and your configuration?

weilbith commented 1 year ago

My version is: NVIM v0.10.0-dev-1913041

And my configuration is basically this:

require('packer').use({
  'LiadOz/nvim-dap-repl-highlights',
  requires = 'nvim-treesitter/nvim-treesitter',
  ft = 'dap-repl',
  config = function()
    require('nvim-dap-repl-highlights').setup()
  end,
  run = function()
    require('nvim-dap-repl-highlights').setup()
    vim.cmd('TSInstall dap_repl')
  end,
})
LiadOz commented 1 year ago

Can you try removing the ft line?

weilbith commented 1 year ago

I did. Unfortunately doesn't help. I also run the :lua require('nvim-dap-repl-highlights').setup_highlights('python') again. Though if I type some code in the REPL buffer, it just remains the "default" highlight. 🤷🏾 Can I maybe use treesitter tools to inspect things?

LiadOz commented 1 year ago

You can do the following to check if the issue is in the parsing side:

  1. Remove the call for require('nvim-dap-repl-highlights').setup() in the config.
  2. Open a new buffer with name scratch (without any extension)
  3. Paste the following as content -
    dap> def hi():
    dap>     pass
  4. Run :require('nvim-dap-repl-highlights').setup() then :lua require('nvim-dap-repl-highlights').setup_highlights('python') in the scratch buffer.
  5. The scratch buffer should now have highlights.

This should trigger the highlighting manually and will rule out configuration issues.

weilbith commented 1 year ago

Thanks for the instructions. So I just opened NeoVim and executed :edit scratch and followed your instructions. Indeed something happened: the dap> texts became grey. But the rest remains white as normal. Is that the expected behavior? I would have expected the function definition to be highlighted. In the screenshot below I have the buffer as instructed by you on the left. On the right is a buffer I set the filetype to Python and removed the dap> parts of the code. image

LiadOz commented 1 year ago

Can you ensure you have the python parser installed and try again, use :TSInstall python

weilbith commented 1 year ago

Well, I thought the right buffer shows that my Python is working fine. I can also open the :TSPlayground and inspect the syntax tree.