halfbrained / cuda_lsp

LSP Client plugin for CudaText
6 stars 4 forks source link

Bash: completion inserts 'rmdir()' #117

Closed Alexey-T closed 1 year ago

Alexey-T commented 1 year ago

On ubuntu i see ok completions.

Screenshot from 2022-09-16 03-01-50

but cmd names are inserted with (): eg rmdir(). @veksha

veksha commented 1 year ago

also if I press ctrl+space on empty line and choose something - no text will be added.

Alexey-T commented 1 year ago

Yes, confirmed it

veksha commented 1 year ago

but cmd names are inserted with ():

Sublime has support for "completion snippets", therefore it doesn't insert () manually. It relies on lsp-server snippet text.

For CudaText snippetSupport is set to False, so Cuda_LSP is manually inserting () based on "completion item kind" (i.e. if function/method then insert ())

I enabled support for snippets format (simply set snippetSupport to True in CAPABILITIES) https://github.com/CudaText-addons/cuda_lsp/pull/21

now we can get func() text from server, (no need to manually insert parentheses) but snippets could be not just plain text, it could be a lot more then simple text. I don't know anything about it yet, but I created this draft PR so we can test it and see how it behaves with different lsp-servers.

veksha commented 1 year ago

maybe you, @Alexey-T , know something about this snippet format:

image

veksha commented 1 year ago

I see that for bash it now doesn't insert (), (like in Sublime) for clangd it inserts () (like in Sublime) for python it doesn't insert () (like in Sublime)

Alexey-T commented 1 year ago

Yes I know about this snip-format. we use it (almost it) in Snippets plug. And you cannot just insert snippets text for any complex snippet, if it has tabstops.

https://wiki.freepascal.org/CudaText_plugins#Format_of_snippet_files

Alexey-T commented 1 year ago

If you got from server snippet-text with tabstops (find ${ ) then we are in bad situation

veksha commented 1 year ago

We need lsp-server that will provide us with complex snippets, so we can test it.

Alexey-T commented 1 year ago

Can we ask (the detailed question) at https://github.com/sublimelsp/LSP/issues ?

veksha commented 1 year ago

code from sublimelsp:

        if item.get("insertTextFormat", InsertTextFormat.PlainText) == InsertTextFormat.Snippet:
            self.view.run_command("insert_snippet", {"contents": new_text})
        else:
            self.view.run_command("insert", {"characters": new_text})

as you can see Sublime Text have internal command "insert_snippet" which is inside closed sources.

Alexey-T commented 1 year ago

We have 'insert-snippet' code in open source! can you grab it from Snippets plugin?

veksha commented 1 year ago

OK

eltonfabricio10 commented 1 year ago

This is interesting!

Peek 16-09-2022 20-42

veksha commented 1 year ago

@eltonfabricio10 do you have another completion addon enabled? or only Cuda_lsp? maybe snippets addon?

eltonfabricio10 commented 1 year ago

Cuda_lsp and complete_from_text(lexers=-,ini files,markdown,restructuredtext,properties,bash script)

I removed lexer bash from complete_from_text... Now it's working as I want... Sorry for my wrong configuration.

Alexey-T commented 1 year ago

@veksha No, that was a plugin bug, see #120 .

If you see 'warnings' instead of 'errors' - it is Shellcheck issue! please report to them. maybe Windows version differs from Linux?

Sample bash file giving 'errors' for me

#/bin/sh
cp -rf $from/data $app/Contents/Resources
cp -rf $from/settings_default $app/Contents/Resources

mkdir $app/Contents/Resources/py/cuda_comments
[[sdfsdf 343 --:::
] [[[sdfsdf #$#$ #$#$mkdir $app/Contents/Resources/py/cuda_new_file
)) (sdfsdf #$#$ #$#$mkdir $app/Contents/Resources/py/cuda_new_file
zdf
veksha commented 1 year ago

If you see 'warnings' instead of 'errors' - it is Shellcheck issue! please report to them. maybe Windows version differs from Linux?

I see errors now! just not for "zdf" kind of lines. I don't see a lot of keywords like "rm", "rmdir", (etc) in the list. it's issue of server.

veksha commented 1 year ago

but cmd names are inserted with (): eg rmdir().

with snippetSupport branch merged parentheses will be inserted by lsp-server, not by lsp-client. so this issue can now be closed.