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

Standalone installation instructions #13

Open
enderger opened this issue Jun 5, 2022 · 10 comments
Open

Standalone installation instructions #13

enderger opened this issue Jun 5, 2022 · 10 comments

Comments

@enderger
Copy link

enderger commented Jun 5, 2022

Currently, there is no information on separating the language server from the VSCode extension. For users of other editors, it might be good to provide instructions for installing the server outside of VSCode to be used in something like Neovim.

@Simerax
Copy link

Simerax commented Feb 9, 2023

> git clone https://github.com/bscan/RakuNavigator
> cd RakuNavigator
> npm install
> npm run compile

Now you should be able to run the server for neovim with node server/out/server.js --stdio

Ps. im trying to solve the same problem as you (using it in neovim) i don't know if this is the "recommended" way to get it up and running but so far it looks promising.

@bscan
Copy link
Owner

bscan commented Feb 9, 2023

Hi @Simerax and @enderger . Yes, that's the recommended method for getting it running. The https://github.com/bscan/PerlNavigator docs have more information about this type of configuration, as the Perl and Raku Navigators both share the same architecture. For the Perl version, it also can be downloaded from NPM, which is something I'd like to add here.

Pull requests would also be more than welcome. The settings will likely vary per editor, so crowdsourcing this would be helpful.

@rcmlz
Copy link

rcmlz commented Feb 9, 2024

Jupyter Lab

I followed the instructions on the PerlNavigator site to install RakuNavigator into /Users/me/.raku/RakuNavigator and configured it for Sublime. That worked fine.

To use RakuNavigator with JupyterLab I created a file raku-language-server-implementation.json

{
  "LanguageServerManager": {
    "language_servers": {
      "raku-language-server": {
        "version": 2,
        "argv": ["node", "/Users/me/.raku/RakuNavigator/server/out/server.js", "--stdio"],
        "languages": ["raku"],
        "mime_types": ["text/raku", "text/x-raku"],
        "display_name": "Raku Language Server"
      }
    }
  }
}

in the directory /Users/me/.virtualenvs/PROJECT/etc/jupyter/jupyter_server_config.d/ following the example here. Use a different path from jupyter --paths if needed.

After tweaking the Raku-Kernel to use "mimetype": "text/x-raku", instead of "mimetype": "text/plain" for new Notebooks (basically search/replace) it worked. Will do a PR, maybe the change gets included.

raku-lsp-jupyter-lab

@7stud
Copy link

7stud commented Feb 23, 2024

@bscan,

I couldn't get the Raku language server to work with emacs 29.1. I did these steps:

git clone https://github.com/bscan/RakuNavigator.git
cd RakuNavigator
npm install
npm run compile

Then I went to the PerlNavigator repo, where there are instructions for emacs and eglot, and I converted the following PerlNavigator configuration:

(setq-default eglot-workspace-configuration
                '((:perlnavigator . (:perlPath
                              "/path/to/perl"
                              :enableWarnings t))))

(with-eval-after-load 'eglot
  (add-to-list 'eglot-server-programs
               `((cperl-mode perl-mode) . ("/path/to/perlnavigator", "--stdio"))))

(global-company-mode)

(add-hook 'cperl-mode-hook 'eglot-ensure)
(add-hook 'perl-mode-hook 'eglot-ensure)

to this RakuNavigator configuration:

(setq-default eglot-workspace-configuration
    '((:rakunavigator . (:rakuPath
                         "/usr/local/bin/rakudo-moar-2024.01-01-macos-arm64-clang/bin/raku"
                          :enableWarnings t))))

(with-eval-after-load 'eglot
  (add-to-list 'eglot-server-programs
      `((raku-mode) . ("/Users/7stud/RakuNavigator/server/out/server.js", "--stdio"))))

(global-company-mode)

;;(add-hook 'cperl-mode-hook 'eglot-ensure)
(add-hook 'raku-mode-hook 'eglot-ensure)

I added the RakuNavigator configuration to my .emacs file. Then I did:

~$ cd ./RakuNavigator/server/out
RakuNavigator/server/out$ chmod a+x server.js

to make server.js executable.

Then I installed the company package. In emacs:

M-x list-packages
C-s company (then C-s repeatedly until I found the company package).
I typed an i with the cursor on the company line.
I typed an x, which installed the company package.

Then I restarted emacs, and I opened the file b.raku and the mode line specified (Raku company), then I did:

M-x eglot <Ret>

but I got the error:

Doing vfork: Exec format error

Here's the full output:

Loading /opt/local/share/emacs/site-lisp/subdirs.el (source)...done  
Loading /Users/7stud/.emacs.d/custom.el (source)...done  
For information about GNU Emacs and the GNU system, type C-h C-a.  
b.raku has auto save data; consider M-x recover-this-file  
Error in post-command-hook (#\[0 "\\303\\301!\\205��r\\301q\\210\\304\\305\\300\\242\\306#\\210  
?\\205��\\307\\310\\311 \\")\\207" \[(#0) #<buffer b.raku> eglot--managed-mode buffer-live-p remove-hook post-command-hook t apply eglot--connect eglot--guess-contact\] 4\]): (file-error "Doing vfork" "Exec format error")  
Doing vfork: Exec format error

In the buffer containing my raku file, I don't get any language hints when I put the cursor on a function or anything else that would make me think the language server is working.

C-h v eglot-server-programs yields:

...
...

Value:
(((raku-mode)
  "/Users/7stud/RakuNavigator/server/out/server.js" "--stdio")
 ((rust-ts-mode rust-mode)
  . #f(compiled-function
       (&optional interactive)
       #<bytecode -0x150b7818629c4e00>))
 ((cmake-mode cmake-ts-mode)
  "cmake-language-server")

...
...

Here's some debug output:

Debugger entered--Lisp error: (file-error "Doing vfork" "Exec format error")
  make-process(:name "EGLOT (raku_programs/(raku-mode))" :command ("/Users/7stud/RakuNavigator/server/out/server.js" "--stdio") :connection-type pipe :coding utf-8-emacs-unix :noquery t :stderr #<buffer *EGLOT (raku_programs/(raku-mode)) stderr*> :file-handler t)
  #f(compiled-function () #<bytecode 0x9056aa22b2ee02b>)()
  #f(compiled-function (cl--cnm conn slots) #<bytecode 0xafdb99b87c0c1e2>)(#f(compiled-function (&rest args) #<bytecode -0x7451545b80f0461>) #<eglot-lsp-server eglot-lsp-server-42f46ca8> (:name "EGLOT (raku_programs/(raku-mode))" :events-buffer-scrollback-size 2000000 :notification-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccb16b9f61>) :request-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccc4eb9f61>) :on-shutdown eglot--on-shutdown :process #f(compiled-function () #<bytecode 0x9056aa22b2ee02b>)))
  apply(#f(compiled-function (cl--cnm conn slots) #<bytecode 0xafdb99b87c0c1e2>) #f(compiled-function (&rest args) #<bytecode -0x7451545b80f0461>) (#<eglot-lsp-server eglot-lsp-server-42f46ca8> (:name "EGLOT (raku_programs/(raku-mode))" :events-buffer-scrollback-size 2000000 :notification-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccb16b9f61>) :request-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccc4eb9f61>) :on-shutdown eglot--on-shutdown :process #f(compiled-function () #<bytecode 0x9056aa22b2ee02b>))))
  #f(compiled-function (conn slots) #<bytecode 0x1a118c40b71591b9>)(#<eglot-lsp-server eglot-lsp-server-42f46ca8> (:name "EGLOT (raku_programs/(raku-mode))" :events-buffer-scrollback-size 2000000 :notification-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccb16b9f61>) :request-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccc4eb9f61>) :on-shutdown eglot--on-shutdown :process #f(compiled-function () #<bytecode 0x9056aa22b2ee02b>)))
  apply(#f(compiled-function (conn slots) #<bytecode 0x1a118c40b71591b9>) (#<eglot-lsp-server eglot-lsp-server-42f46ca8> (:name "EGLOT (raku_programs/(raku-mode))" :events-buffer-scrollback-size 2000000 :notification-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccb16b9f61>) :request-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccc4eb9f61>) :on-shutdown eglot--on-shutdown :process #f(compiled-function () #<bytecode 0x9056aa22b2ee02b>))))
  #f(compiled-function (&rest args) #<bytecode -0x1621c4701db12a08>)(#<eglot-lsp-server eglot-lsp-server-42f46ca8> (:name "EGLOT (raku_programs/(raku-mode))" :events-buffer-scrollback-size 2000000 :notification-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccb16b9f61>) :request-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccc4eb9f61>) :on-shutdown eglot--on-shutdown :process #f(compiled-function () #<bytecode 0x9056aa22b2ee02b>)))
  apply(#f(compiled-function (&rest args) #<bytecode -0x1621c4701db12a08>) #<eglot-lsp-server eglot-lsp-server-42f46ca8> (:name "EGLOT (raku_programs/(raku-mode))" :events-buffer-scrollback-size 2000000 :notification-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccb16b9f61>) :request-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccc4eb9f61>) :on-shutdown eglot--on-shutdown :process #f(compiled-function () #<bytecode 0x9056aa22b2ee02b>)))
  initialize-instance(#<eglot-lsp-server eglot-lsp-server-42f46ca8> (:name "EGLOT (raku_programs/(raku-mode))" :events-buffer-scrollback-size 2000000 :notification-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccb16b9f61>) :request-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccc4eb9f61>) :on-shutdown eglot--on-shutdown :process #f(compiled-function () #<bytecode 0x9056aa22b2ee02b>)))
  #f(compiled-function (class &rest slots) "Default constructor for CLASS `eieio-default-superclass'.\nSLOTS are the initialization slots used by `initialize-instance'.\nThis static method is called when an object is constructed.\nIt allocates the vector used to represent an EIEIO object, and then\ncalls `initialize-instance' on that object." #<bytecode 0x1345cf428cfc9403>)(eglot-lsp-server :name "EGLOT (raku_programs/(raku-mode))" :events-buffer-scrollback-size 2000000 :notification-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccb16b9f61>) :request-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccc4eb9f61>) :on-shutdown eglot--on-shutdown :process #f(compiled-function () #<bytecode 0x9056aa22b2ee02b>))
  apply(#f(compiled-function (class &rest slots) "Default constructor for CLASS `eieio-default-superclass'.\nSLOTS are the initialization slots used by `initialize-instance'.\nThis static method is called when an object is constructed.\nIt allocates the vector used to represent an EIEIO object, and then\ncalls `initialize-instance' on that object." #<bytecode 0x1345cf428cfc9403>) eglot-lsp-server (:name "EGLOT (raku_programs/(raku-mode))" :events-buffer-scrollback-size 2000000 :notification-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccb16b9f61>) :request-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccc4eb9f61>) :on-shutdown eglot--on-shutdown :process #f(compiled-function () #<bytecode 0x9056aa22b2ee02b>)))
  make-instance(eglot-lsp-server :name "EGLOT (raku_programs/(raku-mode))" :events-buffer-scrollback-size 2000000 :notification-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccb16b9f61>) :request-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccc4eb9f61>) :on-shutdown eglot--on-shutdown :process #f(compiled-function () #<bytecode 0x9056aa22b2ee02b>))
  apply(make-instance eglot-lsp-server :name "EGLOT (raku_programs/(raku-mode))" :events-buffer-scrollback-size 2000000 :notification-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccb16b9f61>) :request-dispatcher #f(compiled-function (server method params) #<bytecode -0xa314bccc4eb9f61>) :on-shutdown eglot--on-shutdown (:process #f(compiled-function () #<bytecode 0x9056aa22b2ee02b>)))
  eglot--connect((raku-mode) (transient . "/Users/7stud/raku_programs/") eglot-lsp-server ("/Users/7stud/RakuNavigator/server/out/server.js" "--stdio") "raku")
  eglot((raku-mode) (transient . "/Users/7stud/raku_programs/") eglot-lsp-server ("/Users/7stud/RakuNavigator/server/out/server.js" "--stdio") "raku" t)
  funcall-interactively(eglot (raku-mode) (transient . "/Users/7stud/raku_programs/") eglot-lsp-server ("/Users/7stud/RakuNavigator/server/out/server.js" "--stdio") "raku" t)
  command-execute(eglot record)
  execute-extended-command(nil "eglot" "eglot")
  funcall-interactively(execute-extended-command nil "eglot" "eglot")
  command-execute(execute-extended-command)

@bscan
Copy link
Owner

bscan commented Feb 28, 2024

Hi @7stud, I believe the issue is that server.js is not an executable. For perlnavigator, I provide an executable that is installed in /usr/local/bin automatically when you npm install perlnavigator-server (see here: https://github.com/bscan/PerlNavigator/blob/main/server/bin/perlnavigator )

For the Raku version, I have not yet uploaded this to npm or added the executable. In the meantime, you can preface the command with "node" and it should work. See the comment from @rcmlz as well where they used this as a command:

"argv": ["node", "/Users/me/.raku/RakuNavigator/server/out/server.js", "--stdio"],

@luolong
Copy link

luolong commented Apr 20, 2024

There's lots of good information here, but could I sugest adding installation instructions to README documentation per editor?

@bo-tato
Copy link

bo-tato commented Nov 30, 2024

It is working for me in emacs, installing as in #13 (comment) and then:

(with-eval-after-load 'lsp-mode
  (add-to-list 'lsp-language-id-configuration '(raku-mode . "raku"))

  (lsp-register-client (make-lsp-client
                        :new-connection (lsp-stdio-connection '("node" "/home/user/RakuNavigator/server/out/server.js" "--stdio"))
                        :activation-fn (lsp-activate-on "raku")
                        :server-id 'raku-navigator)))

However it is extremely limited. I don't have VSCode installed to test, so I'm not sure if in VSCode it has more functionality and I haven't fully configured it right. It only completes symbols in my code, not from the standard library, and sometimes gets wrong which symbols are in scope for completion. The doc doesn't show docstrings, just (subroutine) name.

@bscan
Copy link
Owner

bscan commented Dec 2, 2024

Hi @bo-tato, glad it's working. A pull-request on how to get this working in emacs would certainly be welcome. There is similar documentation on the Perl Navigator that could be of use: https://github.com/bscan/PerlNavigator#emacs

Yes, the functionality is currently limited. For autocompletion, it does not currently consider scope. It also supports autocompletion of installed modules, including docstrings, plus go-to definition to those modules.

image

Another nice feature is the reporting of DocumentSymbol which vscode uses heavily. Here's an example showing the outline view on the left, the "sticky scroll" feature where it pins the line of code containing the class, and the breadcrumbs.
image

The other key feature is syntax checking where it compiles the code and gets diagnostics from the raku compiler:

image

Although generally speaking, you are correct that this language server is missing a variety of features (e.g. code formatting, standard library functions and docs, parsing all files in a project, better understanding of scope). I've had much more success with the Perl version, both in terms of the features it supports, and the larger community of contributors. I'd certainly love some help with this project if anyone is interested in collaborating.

@bo-tato
Copy link

bo-tato commented Dec 2, 2024

Thanks a lot for the great answer and images. It is working like that for completion and documentation of module names. Other than module names I think it doesn't support docstrings yet? If I have:

#| some doc for foo
sub foo { say "foo" }
say &foo.WHY;

and request lsp documentation with the cursor on foo, it just says (subroutine) foo without the docstring. And it doesn't show any documentation for say or any other method.
The current raku-mode for emacs does support the equivalent of documentsymbols (through SMIE, basic grammar that somewhat parses raku) and syntax checking (through flycheck). It's goto definition is just simple text search though, raku navigator's goto definition is better. I was hoping for more display of documentation and autocompletion but it seems that's limited for now. For adding emacs instructions to the documentation, it should probably be using eglot rather than lsp-mode. eglot is the now standard, included in emacs by default, lsp client. I just happen to still be using the older 3rd party lsp-mode.

Right now I'm just at the stage of playing around a little with Raku. But if I do actually end up adopting it as a language I use for scripting or coding then I would be interested in collaborating on improving the lsp and editor support

@bscan
Copy link
Owner

bscan commented Dec 2, 2024

Thanks @bo-tato, sounds great! It does not support docstrings yet, but that would be a great addition. Should be straightforward since it's already parsing documentation. And yes, I'd love to collaborate if you continue down the path of using Raku.

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

No branches or pull requests

7 participants