folke / twilight.nvim

🌅 Twilight is a Lua plugin for Neovim 0.5 that dims inactive portions of the code you're editing using TreeSitter.
Apache License 2.0
1.24k stars 21 forks source link

Added option node_context #21

Open mkonig opened 2 years ago

mkonig commented 2 years ago

Adding an option that adds context by nodes in addition to context by lines. Example:

def myfunc():
  if var = number:
    if other = that:    
      print("yes")   <- Cursor is here

If node_context = 1, then both if would be highlighted. If node_context = 0, then only the inner if would be highlighted. if node_context = 2, then the whole function woudl be highlighted.

denstiny commented 2 years ago

For c/CPP have no effect

mkonig commented 2 years ago

Hi

I had to tsplayground to find how the elements for a language are named. For example for cpp ts uses function_definition. If you use expand, then you can define whice elements of a language should be used to expand.

This is my current setup. It does not include cpp.

require'twilight'.setup{ dimming = { alpha = 0.1, }, expand = { "function", -- "if_expression", -- python/pyright "while_statement", "if_statement", "for_statement", "function_definition", "class_definition", -- yml "document", -- lua "function_declaration", "while_statement", "if_statement", }, exclude = { "zsh", "markdown", "help", "asciidoc", "conf", "sh", "vim" }, context = 0, node_context = 2, treesitter = true, }

denstiny commented 2 years ago

你好

我必须到 tsplayground 才能找到一种语言的元素是如何命名的。 例如对于 cpp ts 使用 function_definition。 如果您使用扩展,那么您可以定义一种语言的哪些元素应该用于扩展。

这是我目前的设置。 它不包括 cpp。

需要'暮光'.setup{ 调光 = { 阿尔法 = 0.1, }, 展开 = { “功能”, -- "if_expression", --python/pyright "while_statement", "if_statement", "for_statement", "函数定义", “类定义”, - yml “文档”, - 拿 "function_declaration", "while_statement", "if_statement", }, exclude = { "zsh", "markdown", "help", "asciidoc", "conf", "sh", "vim" }, context = 0, node_context = 2, treesitter = true, }

I think I succeeded.

github-actions[bot] commented 1 month ago

This PR is stale because it has been open 60 days with no activity.