Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function arguments autocomplete for Odin LSP server #5872

Open
CortexReaver opened this issue Feb 23, 2025 · 18 comments
Open

Function arguments autocomplete for Odin LSP server #5872

CortexReaver opened this issue Feb 23, 2025 · 18 comments
Labels

Comments

@CortexReaver
Copy link

CortexReaver commented Feb 23, 2025

Subj, recently I tried to setup LSP for Odin on Cudatext and overall it worked, but still I cannot figure out how to enable API functions auto suggestions. Seems like Odin LSP does support it, because I've seen how it working with LSP in Sublime:

Image

or it can suggests some variables

Image

But no such suggestions in Cudetext. Is this will be even possible to implement or not?

The screenshots were taken from this video: https://www.youtube.com/live/NYsTQ2TcF_0?si=26durYjB2xhit99T&t=1389

@Alexey-T Alexey-T changed the title Function arguments autocomplete Function arguments autocomplete for Odin Feb 23, 2025
@Alexey-T
Copy link
Owner

Does Sublime have some settings for Odin server, maybe in some config file? Maybe Sublime uses some middleware python code to configure Odin server? I cannot find it in the PackageControl.io site.

@CortexReaver
Copy link
Author

So it does work for other languages? Because I've tried it only with C and Odin.
I will try Odin LSP with Sublime later.

@Alexey-T
Copy link
Owner

Alexey-T commented Feb 23, 2025

Yes, Cud's LSP plugin works good with many languages eg C++ and Python, as documented in the wiki page "cudatext plugins".

@Alexey-T Alexey-T changed the title Function arguments autocomplete for Odin Function arguments autocomplete for Odin LSP server Feb 23, 2025
@Alexey-T
Copy link
Owner

I asked for help at the Github issue linked above this post. Maybe you should click Cud's LSP sidebar icon, panel will be shown at the bottom. Read its log. Maybe LSP server was not inited ok?

@CortexReaver
Copy link
Author

CortexReaver commented Feb 24, 2025

This is how it looks for me:

Image

syntaxis suggestions works perfectly, that for sure. Is it supposed to be like this? Maybe I've hide the log somehow?

@CortexReaver
Copy link
Author

My lsp_odin.json in the "cudatext\settings" folder:

{
  "lexers": {
    "Odin": "odin"
  },
    "cmd_windows": [
    "ols.exe"
  ],
	"enable_semantic_tokens": true,
	"enable_document_symbols": true,
	"enable_hover": true,
	"enable_snippets": true
}

Do I need to copy it anywhere else?

@CortexReaver
Copy link
Author

CortexReaver commented Feb 24, 2025

Installed LSP plugin with Lexer Odin on clean version or Cudatext:

Image

Image

No result.

@Alexey-T
Copy link
Owner

Alexey-T commented Feb 24, 2025

I cannot make Odin server showing anything, so cannot help.+

  • installed MS Build Tools 2022
  • unzipped Odin last release, added dir to PATH
  • unzipped LSP server, added it to PATH, renamed .exe file to ols.exe
  • made settings/lsp_odin.json
{
  "lexers": {
    "Odin": "odin"
  },
  "cmd_windows": [ "C:\\Work\\odin_server\\ols.exe" ],
	"enable_semantic_tokens": true,
	"enable_document_symbols": true,
	"enable_hover": true,
	"enable_snippets": true,
	"enable_format": true,
	"log_stderr": true
}

from Console, odin.exe works, ols.exe works somehow too.
now from Cud, I see in Console panel

LSP: starting server - Odin; root: None
Init: cuda_runner
Init: cudatext
LSP: Odin - process exited

and now autocompletion don't work for your file 'new.odin' here: prin|t. LSP panel in Cud shows only 1 error:

stderr: D:/a/ols/ols/src/server/requests.odin(1450:58) Index 0 is out of range 0..<0

@CortexReaver
Copy link
Author

CortexReaver commented Feb 24, 2025

Is "MS Build Tools 2022" a requeirment?
Bcause I've used this script: https://gist.github.com/mmozeiko/7f3162ec2988e81e56d5c4e22cde9977
Since this is in the oficial Odin guide: https://odin-lang.org/docs/install/

@Alexey-T
Copy link
Owner

I am not sure MSBuildTools are used during lsp action.
I think this Console line

LSP: Odin - process exited

means that lsp server exits. So it dont work for me. If you have idea how to fix it, tell me.

@Alexey-T
Copy link
Owner

Alexey-T commented Feb 24, 2025

I found why 'process exited'! reason: I did not create PROJECT with tst.odin file which I edit. after I made the project and saved it as tst.cuda-proj in the same dir as tst.odin, completions work!

tst.odin

package tst;

import "core:fmt";

main :: proc(){
	value: u128;
	using fmt;
	print()
}

proof that it works:

Image

my settings/lsp_odin.json.

{
  "lexers": {
    "Odin": "odin"
  },
  "cmd_windows": [ "ols.exe" ]
}

note that I copied ols.exe to the same dir as odin.exe.

@Alexey-T
Copy link
Owner

Alexey-T commented Feb 24, 2025

I wrote my results to the wiki.
https://wiki.freepascal.org/CudaText_plugins#LSP_server_for_Odin

@Alexey-T
Copy link
Owner

Functions call-tooltip works too! good! I press Ctrl+Shift+Space here:

print(|)

@CortexReaver

This comment has been minimized.

@CortexReaver
Copy link
Author

No luck, now I've got this error when I try to press shft+ctrl+space inside function parentheses:

Image

@Alexey-T
Copy link
Owner

This error log shows that you have very old LSP_Client plugin! it is using already deleted api. update LSP_Client from 'plugins / addon manager / update'.

@CortexReaver
Copy link
Author

CortexReaver commented Feb 24, 2025

Ok, now it works. One more thing: "base" folder from odin main folder must be included in a project (root nodes -> add folder) in order for LSP to work correctly.

@Alexey-T
Copy link
Owner

Added this info to the wiki topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants