Giter Site home page Giter Site logo

Comments (12)

yyoncho avatar yyoncho commented on August 11, 2024 1

I pushed a fix about the duplicate name.

from lsp-treemacs.

yyoncho avatar yyoncho commented on August 11, 2024 1

Yes, please ignore the previous comment, apparently, there is pyls specific an issue. I will investigate.

from lsp-treemacs.

yyoncho avatar yyoncho commented on August 11, 2024 1

No, it is an issue in lsp-treemacs-symbols , I will fix it. It is caused by pyls not returning hierarchical elements. This was the old documentSymbols format.

from lsp-treemacs.

yyoncho avatar yyoncho commented on August 11, 2024 1

Proposed fix at #27

I will test it for some time before before merging.

from lsp-treemacs.

yyoncho avatar yyoncho commented on August 11, 2024

Can you post a screenshot about the identation issues?

from lsp-treemacs.

algoterranean avatar algoterranean commented on August 11, 2024

Using this Python code:

import os
import sys

class Example:
    def __init__(self):
        self.x = 1

I would expect lsp-treemacs-symbols-list to display the symbols like, say:

os
sys
Example
     __init__
        x

What I get is (with your 2nd defun):

image

What I get (with the 1st defun):

image

It looks like (seq-empty-p children) is always true.

FWIW, evaluating

(lsp-request "textDocument/documentSymbol" `(:textDocument ,(lsp--text-document-identifier)))

in my code buffer gives me:

(#s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (name os containerName nil location #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (uri file:///mnt/projects/t.py range #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (start #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 0 character 0)) end #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 0 character 9)))))) kind 2)) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (name sys containerName nil location #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (uri file:///mnt/projects/t.py range #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (start #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 1 character 0)) end #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 1 character 10)))))) kind 2)) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (name Example containerName nil location #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (uri file:///mnt/projects/t.py range #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (start #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 3 character 0)) end #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 6 character 0)))))) kind 5)) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (name __init__ containerName Example location #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (uri file:///mnt/projects/t.py range #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (start #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 4 character 4)) end #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 6 character 0)))))) kind 12)) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (name x containerName __init__ location #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (uri file:///mnt/projects/t.py range #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (start #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 5 character 8)) end #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 5 character 18)))))) kind 13)))

Not sure if children is supposed to be included in this return value, but it does include a containerName reference.

I am using Palantir's python language server for this (https://github.com/palantir/python-language-server) not the MS one, if that makes a difference.

from lsp-treemacs.

yyoncho avatar yyoncho commented on August 11, 2024

Ah, I see - the offset is the expected behaviour here it is the explanation:

Screenshot

Note that in order to have the nodes without children aligned to the nodes with children aligned we have to indent then in the same way.

VScode works in the same way:
Screenshot

from lsp-treemacs.

algoterranean avatar algoterranean commented on August 11, 2024

Shouldn't the expected behavior though be to have, for example, __init__ indented as a child of Example, since it is a method?

from lsp-treemacs.

algoterranean avatar algoterranean commented on August 11, 2024

Using the MS python language server seems to fix the indentation issue:

image

And this backend does return a children node:

(#s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (name os kind 2 deprecated nil range #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (start #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 0 character 7)) end #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 0 character 9)))) selectionRange #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (start #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 0 character 7)) end #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 0 character 9)))) children [])) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (name sys kind 2 deprecated nil range #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (start #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 1 character 7)) end #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 1 character 10)))) selectionRange #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (start #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 1 character 7)) end #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 1 character 10)))) children [])) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (name Example kind 5 deprecated nil range #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (start #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 3 character 0)) end #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 5 character 18)))) selectionRange #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (start #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 3 character 6)) end #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 3 character 13)))) children [#s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (name __init__ kind 9 deprecated nil range #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (start #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 4 character 4)) end #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 5 character 18)))) selectionRange #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (start #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 4 character 8)) end #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 4 character 16)))) children [#s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (name self kind 13 deprecated nil range #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (start #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 4 character 17)) end #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 4 character 21)))) selectionRange #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (start #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 4 character 17)) end #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (line 4 character 21)))) children []))]))])))

Note though that self.x doesn't show up in the symbols list, but it's also not being returned from the backend as far as I can tell. So maybe I need to fool around with the config options for this LSP server.

from lsp-treemacs.

algoterranean avatar algoterranean commented on August 11, 2024

Thanks. The patch is working well for me so far!

from lsp-treemacs.

algoterranean avatar algoterranean commented on August 11, 2024

Actually, I noticed the symbols list is being truncated after the first class or defun. For example:

def test():
    x = 20
    
class Something:
    def __init__(self):
        x = 20
        
    def what(self):
        y = 90

Shows
image

and

class Something:
    def __init__(self):
        x = 20
        
    def what(self):
        y = 90


def test():
    x = 20 

Shows
image

Note that there looks to be a partial problem with indentation.

from lsp-treemacs.

yyoncho avatar yyoncho commented on August 11, 2024

@algoterranean pushed a fix, I was using the wrong function -split-with instead of -separate.

from lsp-treemacs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.