ldelossa / litee.nvim

A framework for building Neovim plugins
409 stars 14 forks source link

Feature request: Ability to hide non-user written methods #16

Closed quantum-booty closed 2 years ago

quantum-booty commented 2 years ago

Right now its difficult to distinguish methods from external packages vs methods written by the user. It would be nice to indicate or have the ability to hide external methods. I can imagine that users more often than not, would like to see the calltree of users written methods. For example in the below calltree, I only care about the pad_grid and count_active_neighbours calls, and not the external dependencies circled in red. image

ldelossa commented 2 years ago

Can you elaborate?

quantum-booty commented 2 years ago

Sorry I've updated the description.

ldelossa commented 2 years ago

@quantum-booty I actually just pushed a change which adjusts the UI quite a bit. Can you update the plugin and try it then provide feedback? The change now shows the file's path returned from LSP.

The UI now looks like this

image

As you can see if the location of the function cannot be found within the current workspace directory or current working direction, it will print the full path to the file - I think this indicates its "external"

I'd have to think about if excluding external methods/functions could happen. Since an external function could still be another package in your workspace.

quantum-booty commented 2 years ago

@ldelossa is it possible to print the package name only? The paths can get pretty long and hard to read. image zeros -> numpy shape -> numpy tuple -> stdlib slice -> stdlib etc...

ldelossa commented 2 years ago

yikes, we definitely don't want that.

Here is what VSCode displays when having two internal symbols, and one external:

image

The thing is, I do not like having those long package paths for local symbols, I'd rather just have the file since you can navigate to it easily.

What I'm thinking is a combination of what VSCode does and what I do.

If the symbol belongs to a file which is local in your workspace, we'll just display the relative path to the file.

If we cannot resolve a relative path to the file like in the above case, we'll only show the package/filename details.

ldelossa commented 2 years ago

@quantum-booty I merged the above mentioned logic. Let me know your feedback.

quantum-booty commented 2 years ago

@quantum-booty I merged the above mentioned logic. Let me know your feedback.

Unfortunately Pyright language server doesn't seem to provide "detail" field, below is a list of fields I see. image I still think it would be nice to be able to toggle the visibility of external functions. Maybe mapped to key "."

ldelossa commented 2 years ago

@quantum-booty can you actually do a "print(vim.inspect())" on the call_hierarchy_item table there? Want to see what LSP is giving you back.

quantum-booty commented 2 years ago

@ldelossa Here is print(vim.inspect(node))

{
  call_hierarchy_item = {
    kind = 12,
    name = "print",
    range = {
      end = {
        character = 9,
        line = 1250
      },
      start = {
        character = 4,
        line = 1250
      }
    },
    selectionRange = {
      end = {
        character = 9,
        line = 1250
      },
      start = {
        character = 4,
        line = 1250
      }
    },
    uri = "file:///usr/lib/node_modules/pyright/dist/typeshed-fallback/stdlib/builtins.pyi"
  },
  children = {},
  depth = 1,
  expanded = false,
  key = "print:file:///usr/lib/node_modules/pyright/dist/typeshed-fallback/stdlib/builtins.pyi:1250",
  name = "print",
  references = { {
      end = {
        character = 13,
        line = 258
      },
      start = {
        character = 8,
        line = 258
      }
    } },
  uri = ""
}
{
  kind = 12,
  name = "print",
  range = {
    end = {
      character = 9,
      line = 1250
    },
    start = {
      character = 4,
      line = 1250
    }
  },
  selectionRange = {
    end = {
      character = 9,
      line = 1250
    },
    start = {
      character = 4,
      line = 1250
    }
  },
  uri = "file:///usr/lib/node_modules/pyright/dist/typeshed-fallback/stdlib/builtins.pyi"
}
ldelossa commented 2 years ago

@quantum-booty i'm a little hesitant to hide the external symbols, as I don't see other IDE's doing this.

(Thanks for printing that, not much to use there)

I installed pyright in vscode and looked up an external symbol. It shows the entry but just leaves out any file information:

image

I think I will just do this. If someone does want to know where that external file is on the file system they can press "d" key on the symbol for the details popup.

ldelossa commented 2 years ago

@quantum-booty logic above implemented. give it a try and provide feedback.

quantum-booty commented 2 years ago

@quantum-booty logic above implemented. give it a try and provide feedback.

It looks very nice! Thanks a lot for this feature!