geany-lsp icon indicating copy to clipboard operation
geany-lsp copied to clipboard

Cannot get https://github.com/SemanticWebLanguageServer/swls to work

Open ilu33 opened this issue 5 months ago • 5 comments

I cannot get https://github.com/SemanticWebLanguageServer/swls to load correctly. After several tries I got the build working and the swls server does get started by the plugin. But it does nothing. I managed to configure Geany to know the filetype Turtle/.ttl by adding a custom filetype.Turtle.conf into the user config dir and by adding #Turtle=*.ttl; to filetypes_extensions.conf. The lsp.conf block looks like this:

[Turtle]
cmd=~/swls/target/debug/swls
rpc_log=~/turtle-lsp.log
lang_id_mappings=Turtle;*.ttl

I assume there's something missing on the Geany side (compared to swls' instructions for Vim). I do not get any debug output in the log. This is the server initialize output, if that helps:

{

"~/swls/target/debug/swls":
{
  "capabilities" : {
    "completionProvider" : {
      "resolveProvider" : false,
      "triggerCharacters" : [
        ":"
      ]
    },
    "definitionProvider" : true,
    "documentFormattingProvider" : true,
    "hoverProvider" : true,
    "inlayHintProvider" : true,
    "referencesProvider" : true,
    "renameProvider" : {
      "prepareProvider" : true
    },
    "semanticTokensProvider" : {
      "documentSelector" : [
        {
          "language" : "sparql"
        },
        {
          "language" : "turtle"
        },
        {
          "language" : "jsonld"
        }
      ],
      "full" : true,
      "legend" : {
        "tokenModifiers" : [],
        "tokenTypes" : [
          "boolean",
          "langTag",
          "comment",
          "enumMember",
          "enum",
          "keyword",
          "namespace",
          "number",
          "property",
          "string",
          "variable"
        ]
      },
      "range" : false
    },
    "textDocumentSync" : 1,
    "typeDefinitionProvider" : true
  }
}
}

ilu33 avatar Jul 18 '25 22:07 ilu33

lang_id_mappings=Turtle;*.ttl

Shouldn't Turtle be with lowercase t here? At least from the neovim configuration mentioned here https://github.com/SemanticWebLanguageServer/swls it seems to be the case:

vim.api.nvim_create_autocmd({ "BufNewFile", "BufReadPost" }, {
    pattern = "*.ttl",
    callback = function(args)
        vim.bo[args.buf].filetype = "turtle"
        vim.bo.commentstring = "# %s"
    end,
})

I haven't tested this particular server myself so it's possible there's some other problem. If the above doesn't help, I'll investigate more.

techee avatar Jul 19 '25 08:07 techee

and by adding #Turtle=*.ttl; to filetypes_extensions.conf.

I've just noticed this - there shouldn't be # here, it's a comment. But since the language server started, I assume you have it configured correctly, right?

techee avatar Jul 19 '25 09:07 techee

All lines in filetypes_extensions.conf are commented and the correct document type (Turtle) showed up in Geany since I added the commented line and the filetype.Turtle.conf. Uncommenting the line seems to have not changed anything.

Changing lang_id_mappings from "Turtle;.ttl" to "turtle;.ttl" also seems to do nothing but I'll keep it for now.

11:26:08: This is Geany 2.1.
(lang_id_mappings=Turtle;*.ttl)
18:46:12: Configuration files reloaded.
18:46:30: Starting LSP server ~/swls/target/debug/swls
18:46:30: Failed to create log file: ~/turtle-lsp.log
18:46:30: Sending initialize request to LSP server ~/swls/target/debug/swls
18:46:30: LSP server ~/swls/target/debug/swls initialized
(changing lang_id_mappings=turtle;*.ttl and reload)
18:51:39: File ~/.config/geany/plugins/lsp/lsp.conf saved.
18:51:39: Sending shutdown request to LSP server ~/swls/target/debug/swls
18:51:39: Force terminating LSP server ~/swls/target/debug/swls
18:51:39: LSP server ~/swls/target/debug/swls stopped
18:51:56: Starting LSP server ~/swls/target/debug/swls
18:51:56: Failed to create log file: ~/turtle-lsp.log
18:51:56: Sending initialize request to LSP server ~/swls/target/debug/swls
18:51:57: LSP server ~/swls/target/debug/swls initialized

I can see that swls does something since the hover function works. No idea why the log creation fails. I'll file an issue at swls but I first wanted to check with you in case the problem resides on the Geany side.

ilu33 avatar Jul 19 '25 17:07 ilu33

All lines in filetypes_extensions.conf are commented

Yes, that's true but the reason is that this way you use Geany default values. You can override them by uncommenting individual lines or adding a new one.

Changing lang_id_mappings from "Turtle;.ttl" to "turtle;.ttl" also seems to do nothing but I'll keep it for now.

Just to be sure - it should be turtle;*.ttl (asterisk)

No idea why the log creation fails.

I think I didn't implement ~ expansion for the log files. Try to use an absolute path or set it to stdout to get the result printed in the terminal (if you start Geany from it).

Anyway, I've just tested swls and it seems to "work". By "work" I mean I don't know anything about Turtle or how swls is supposed to work (do you have any experience with this particular server?). I didn't create a new file type but used it with the XML file type by using the following configuration:

[XML]
cmd=/home/parallels/Downloads/semantic-web-lsp/target/release/swls
lang_id_mappings=turtle;*.ttl
rpc_log=stdout
rpc_log_full=false
show_server_stderr=true
semantic_tokens_enable=true

and by adding *.ttl to XML in filetype_extensions.conf.

Semantic tokens don't work because the plugin currently highlights types only (see https://github.com/techee/geany-lsp/issues/76). Diagnostics seem to "work" even though when you make some syntax error, the majority of the lines in the file get underlined with an error. Formatting also seems to work - it behaves in a bit strange way though. Completion also seems to work (for prefixes as the server README describes). I haven't tested rename as I don't know in which situations it's supposed to work and "hover" doesn't seem to work for the file I used for testing (https://github.com/SEMICeu/dcat-ap_validator/blob/master/pages/samples/sample-turtle.ttl) either. But again, I don't know anything about the language myself and don't know if swls is mature enough.

techee avatar Jul 19 '25 18:07 techee

Yes, that's true but the reason is that this way you use Geany default values. You can override them by uncommenting individual lines or adding a new one.

Just to be sure - it should be turtle;*.ttl (asterisk)

I think I didn't implement ~ expansion for the log files. Try to use an absolute path or set it to stdout to get the result printed in the terminal (if you start Geany from it).

Understood. And the asterisk got somehow lost in copy/paste.

Anyway, I've just tested swls and it seems to "work". By "work" I mean I don't know anything about Turtle or how swls is supposed to work (do you have any experience with this particular server?).

I will now get over my general grudge and test swls with vscode. This will take a while. I fully intend to come back to Geany though.

Semantic tokens don't work because the plugin currently highlights types only (see #76).

Thanks for pointing out that issue, +1 to the feature request, I think it correlates with what I was hoping to see.

ilu33 avatar Jul 19 '25 19:07 ilu33