Giter VIP home page Giter VIP logo

emacs-lsp / lsp-mode Goto Github PK

View Code? Open in Web Editor NEW
4.7K 4.7K 855.0 158.2 MB

Emacs client/library for the Language Server Protocol

Home Page: https://emacs-lsp.github.io/lsp-mode

License: GNU General Public License v3.0

Emacs Lisp 99.25% Makefile 0.11% Gherkin 0.05% Python 0.01% TeX 0.26% YASnippet 0.08% HTML 0.24% Shell 0.01%
angular cpp dart emacs eslint golang html java javascript json language-server-client language-server-protocol php python ruby rust scala swift typescript

lsp-mode's Introduction

title description root_file
LSP Mode - Language Server Protocol support for Emacs
Language Server Protocol support with multiples languages support for Emacs
README.md

CI

Language Server Protocol Support for Emacs

LSP mode


homepageinstallationlanguagessettingstutorialstroubleshootingscreenshotsFAQ


Why?

  • ❤️ Community Driven
  • 💎 Fully featured - supports all features in Language Server Protocol v3.14.
  • 🚀 Fast - see performance section.
  • 🌟 Flexible - choose between full-blown IDE with flashy UI or minimal distraction free.
  • ⚙️ Easy to configure - works out of the box and automatically upgrades if additional packages are present.

Overview

Client for Language Server Protocol (v3.14). lsp-mode aims to provide IDE-like experience by providing optional integration with the most popular Emacs packages like company, flycheck and projectile.

  • Non-blocking asynchronous calls
  • Real-time Diagnostics/linting via flycheck (recommended) or flymake when Emacs > 26 (requires flymake>=1.0.5)
  • Code completion - company-capf / completion-at-point (note that company-lsp is no longer supported).
  • Hovers - using lsp-ui
  • Code actions - via lsp-execute-code-action, modeline (recommended) or lsp-ui sideline.
  • Code outline - using builtin imenu or helm-imenu
  • Code navigation - using builtin xref, lsp-treemacs tree views or lsp-ui peek functions.
  • Code lens
  • Symbol highlights
  • Formatting
  • Project errors on modeline
  • Debugger - dap-mode
  • Breadcrumb on headerline
  • Helm integration - helm-lsp
  • Ivy integration - lsp-ivy
  • Consult integration - consult-lsp
  • Treemacs integration - lsp-treemacs
  • Semantic tokens as defined by LSP 3.16 (compatible language servers include recent development builds of clangd and rust-analyzer)
  • which-key integration for better discovery
  • iedit
  • dired
  • ido

Presentations/demos

See also

  • lsp-docker - provide docker image with preconfigured language servers with corresponding emacs configuration.
  • company-box - company frontend with icons.
  • dap-mode - Debugger integration for lsp-mode.
  • eglot - An alternative minimal LSP implementation.
  • which-key - Emacs package that displays available keybindings in popup
  • projectile - Project Interaction Library for Emacs
  • emacs-tree-sitter - Faster, fine-grained code highlighting via tree-sitter.
  • gccemacs - modified Emacs capable of compiling and running Emacs Lisp as native code.

Contributions

Contributions are very much welcome!

NOTE Documentation for clients is generated from doc comments in the clients themselves (see lsp-doc.el) and some metadata (see lsp-clients.json) so please submit corrections accordingly.

Support the project

The emacs-lsp organization has more than 20,000 lines of code, to keep all of this working, we need to implement new features and help the community on a lot of issues.

You can help us keep going and improving it by supporting the project

Members

Here it is a list of the current lsp-mode members and what they are primary working on/responsible for.

kurnevsky
kurnevsky

Scala | Rust
seagle0128
seagle0128

Go | Python MS
sebastiansturm
sebastiansturm

lsp-mode core | C++
vibhavp
vibhavp

lsp-mode core
yyoncho
yyoncho

lsp-mode core | Java
ericdallo
ericdallo

Dart/Flutter | Clojure
danielmartin
danielmartin

C++ | Swift
kiennq
kiennq

completions | pwsh
nbfalcon
nbfalcon

lsp-mode core | iedit
psibi
psibi

Terraform | Nix
razzmatazz
razzmatazz

C# | F#
jcs090218
jcs090218

lsp-mode core

lsp-mode's People

Contributors

alanz avatar brotzeit avatar danielmartin avatar easbarba avatar elken avatar ericdallo avatar flodiebold avatar fredericgiquel avatar gastove avatar gpittarelli avatar itome avatar jcs090218 avatar kiennq avatar kubo39 avatar kurnevsky avatar leungbk avatar maskray avatar mpanarin avatar nbfalcon avatar phst avatar psibi avatar razzmatazz avatar seagle0128 avatar sebastiansturm avatar sebastiencs avatar themkat avatar tigersoldier avatar vibhavp avatar wyuenho avatar yyoncho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lsp-mode's Issues

Extensions / rust diagnostics

I notice rustls uses custom diagnostics.

https://github.com/rust-lang-nursery/rls/blob/88fc39bd654c536b4f8f1cd1fc8245706f0284ec/contributing.md#extensions-to-the-language-server-protocol

"
The RLS uses some custom extensions to the Language Server Protocol. Currently
these are all sent from the RLS to an LSP client and are only used to improve
the user experience by showing progress indicators.

  • rustDocument/diagnosticsBegin: notification, no arguments. Sent before a
    build starts and before any diagnostics from a build are sent.
  • rustDocument/diagnosticsEnd: notification, no arguments. Sent when a build
    is complete (successfully or not, or even skipped) and all post-build analysis
    by the RLS is complete.
    "

See also microsoft/language-server-protocol#70

significant delays when auto-completing for rust language server

On rls alpha version, startup works well, eldoc, goto def seems to be working, etc.

But when autocompleting (with company, for example), emacs seems to lock, and only multiple C-g seem to stop the lockup (but still no completion).

I don't know if this is present with other language servers.

Non ASCII character support

Changing the length function for string-bytes in lsp--make-message is enough to get it working. Here's a text you can try it on: λ=1

error on opening

When i navigate to a rust project, open say lib.rs on initial open i get:

let: Symbol’s function definition is void: hash-table-keys

the rls binary is in my /home/m4b/bin which is in my $PATH

this is in my .emacs

;; lsp
(add-to-list 'load-path "/home/m4b/git/emacs-lsp")
(require 'lsp-mode)
(global-lsp-mode t)

am I doing something wrong?

tabs vs spaces :(

The checked out files have tabs in them.

Would it be possible to set the save functionality on your editor to make them spaces when it saves?

Install instructions + client example

Hello!

Was wondering if you could provide very basic install example, etc, but also, a client example communicating over stdout would be great, or how to setup something like this. (Primarily interested in using this with rust language server binary which uses stdout)

Thanks, and keep up the good work!

"Start a new Language Server" question

At the moment, if I choose not to use LSP for a project, it will ask me every time I open a different file in the project if I want to start a new language server.

Perhaps we should store the fact that for a given project root the answer is currently no.

Emacs hangs

After opening any rust file and answering "yes" to "start server?" question emacs hangs until I press C-g. Any ideas?

Start a new Language Server for this project? (y or n) y
lsp--stdio-send-sync: Content-Length: 145
Content-Type: application/vscode-jsonrpc; charset=utf-8

{"jsonrpc":"2.0","method":"initialize","params":{"processId":13843,"rootPath":"/home/tatrix/Documents/rust/hello/src/","capabilities":{}},"id":1}

Change the project description

It currently says "Emacs client for the Language Server Protocol v2.0 "

It should be "Emacs client for the Language Server Protocol v3.0 "

flycheck in haskell mode

I am getting the following output for flycheck-verify-setup

Any idea what I need to change?

Syntax checkers for buffer Foo.hs in haskell-mode:

  haskell-stack-ghc
    - may enable: yes
    - executable: Found at /usr/bin/stack

  haskell-ghc
    - may enable: yes
    - executable: Found at /opt/ghc/8.0.2/bin/ghc

  haskell-hlint
    - may enable:         yes
    - executable:         Found at /home/alanz/.cabal/bin/hlint
    - configuration file: Not found

Flycheck Mode is enabled. Use SPC u C-c ! x to enable disabled checkers.

--------------------

Flycheck version: 31snapshot (package: 20170324.340)
Emacs version:    25.1.1
System:           x86_64-pc-linux-gnu
Window system:    x

The messaging leading up to it is

{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///home/alanz/tmp/haskell-hie-test-project/src/Foo.hs","languageId":"haskell","version":0,"text":"module Foo where\n\nfoo :: Int\nfoo = 5\n\nbaz = do\n  putStrLn \"hello\"\n\n"}}}
Output from language server: {"params":{"uri":"file:///home/alanz/tmp/haskell-hie-test-project/src/Foo.hs","diagnostics":[{"severity":2,"range":{"start":{"line":6,"character":7},"end":{"line":7,"character":19}},"code":"Redundant do","source":"hlint","message":"baz\ndo putStrLn \"hello\"\nputStrLn \"hello\"\n"}]},"jsonrpc":"2.0","method":"textDocument/publishDiagnostics"}
error in process filter: progn: Error parsing language server output: (error Flycheck cannot use lsp in this buffer, type M-x flycheck-verify-setup for more details)
error in process filter: Error parsing language server output: (error Flycheck cannot use lsp in this buffer, type M-x flycheck-verify-setup for more details)

Controlling DidChangeTextDocument Notification

The documentation for TextDocumentSyncKind offers None, Full, or Incremental.

In vscode this behaves such that omitting the parameter from the server capabilities returned to the client is effectively a fourth option, where DidSave events are generated without sending document contents.

And DidChangeTextDocument notifications are not sent either.

Replicate this behaviour

Relative path not supported in workspace

When opening new project, it asks for project root (also why can't this be found automatically based on file location?)

If We give ~/project/name/ (which is already filled in) the tilde is not expanded and the path is passed to the rls which panics. This could be fixed upstream but probably easiest to just expand the ~ if possible and pass the absolute file path to the server.

Ideally I don't have to type this at all, as it should be discoverable by simply going up from current path until a cargo.toml is found, and if not, only then asking/aborting

lsp--apply-workspace-edit not running hooks properly?

lsp--apply-workspace-edit calls (find-file filename).

According to the documentation this should run the find-file-hook after loading. This is set globally via global-lsp-mode.

But when renaming in a file that causes a change in another file that is not already loaded, I get the following debug error break which seems to indicate that the values required for the timer-event-handler are not properly set up.

Debugger entered--Lisp error: (wrong-type-argument lsp--workspace nil)
  signal(wrong-type-argument (lsp--workspace nil))
  (or (progn nil (and (vectorp lsp--cur-workspace) (>= (length lsp--cur-workspace) 8) (memq (aref lsp--cur-workspace 0) cl-struct-lsp--workspace-tags) t)) (signal (quote wrong-type-argument) (list (quote lsp--workspace) lsp--cur-workspace)))
  (progn nil (or (progn nil (and (vectorp lsp--cur-workspace) (>= (length lsp--cur-workspace) 8) (memq (aref lsp--cur-workspace 0) cl-struct-lsp--workspace-tags) t)) (signal (quote wrong-type-argument) (list (quote lsp--workspace) lsp--cur-workspace))) (aref lsp--cur-workspace 3))
  (let* ((file-versions (progn nil (or (progn nil (and (vectorp lsp--cur-workspace) (>= ... 8) (memq ... cl-struct-lsp--workspace-tags) t)) (signal (quote wrong-type-argument) (list (quote lsp--workspace) lsp--cur-workspace))) (aref lsp--cur-workspace 3))) (rev (gethash buffer-file-name file-versions))) (if inc (progn (setq rev (1+ rev)) (puthash buffer-file-name rev file-versions))) rev)
  lsp--cur-file-version(t)
  lsp--send-changes()
  apply(lsp--send-changes nil)
  timer-event-handler([t 22614 58086 563874 nil lsp--send-changes nil nil 427000])
  read-event(nil t 1)
  sit-for(1 t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer Main.hs> "~/tmp/haskell-hie-test-project/src/Main.hs" nil nil "~/tmp/haskell-hie-test-project/src/Main.hs" (11322162 2049))
  find-file-noselect("/home/alanz/tmp/haskell-hie-test-project/src/Main.hs" nil nil nil)
  find-file("/home/alanz/tmp/haskell-hie-test-project/src/Main.hs")
  (let ((filename (string-remove-prefix "file://" uri))) (message "apply-workspace-edit:filename= %s" filename) (find-file filename) (lsp--apply-text-edits edits))
  lsp--apply-workspace-edit("file:///home/alanz/tmp/haskell-hie-test-project/src/Main.hs" (#s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("range" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("start" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("line" 7 "character" 0 ...)) "end" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("line" 7 "character" 100000 ...)) ...)) "newText" "    putStrLn $ \"Hello, Haskell!:foo=\" ++ show foo" ...))))
  (lambda (key value) (lsp--apply-workspace-edit key value))("file:///home/alanz/tmp/haskell-hie-test-project/src/Main.hs" (#s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("range" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("start" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("line" 7 "character" 0 ...)) "end" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("line" 7 "character" 100000 ...)) ...)) "newText" "    putStrLn $ \"Hello, Haskell!:foo=\" ++ show foo" ...))))
  maphash((lambda (key value) (lsp--apply-workspace-edit key value)) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("file:///home/alanz/tmp/haskell-hie-test-project/src/Foo.hs" (#s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("range" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("start" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("line" 2 "character" 0 ...)) "end" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("line" 3 "character" 100000 ...)) ...)) "newText" "foo :: Int\nfoo = 5" ...))) "file:///home/alanz/tmp/haskell-hie-test-project/src/Main.hs" (#s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("range" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("start" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("line" 7 "character" 0 ...)) "end" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("line" 7 "character" 100000 ...)) ...)) "newText" "    putStrLn $ \"Hello, Haskell!:foo=\" ++ show foo" ...))) ...)))
  lsp--apply-workspace-edits(#s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("changes" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("file:///home/alanz/tmp/haskell-hie-test-project/src/Foo.hs" (#s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("range" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("start" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("line" 2 "character" 0 ...)) "end" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("line" 3 "character" 100000 ...)) ...)) "newText" "foo :: Int\nfoo = 5" ...))) "file:///home/alanz/tmp/haskell-hie-test-project/src/Main.hs" (#s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("range" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("start" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("line" 7 "character" 0 ...)) "end" #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("line" 7 "character" 100000 ...)) ...)) "newText" "    putStrLn $ \"Hello, Haskell!:foo=\" ++ show foo" ...))) ...)) ...)))
  (let ((edits (lsp--send-request (lsp--make-request "textDocument/rename" (lsp--make-document-rename-params newname))))) (lsp--apply-workspace-edits edits))
  lsp-rename("foo")
  funcall-interactively(lsp-rename "foo")
  call-interactively(lsp-rename record nil)
  command-execute(lsp-rename record)
  helm-M-x(nil "lsp-rename")
  funcall-interactively(helm-M-x nil "lsp-rename")
  call-interactively(helm-M-x nil nil)

Community

Perhaps suggest that people wishing to discuss can go to #haskell-emacs on IRC Freenode.

wrong place for Cargo.toml

I use today repo of rls (88fc39bd654c536b4f8f1cd1fc8245706f0284ec), and emacs 25.1.1 on linux amd64.

I create project boo:

cargo new boo

and open src/lib.rs in emacs and all freezes,
Rust Language Server stderr buffer contains:

thread '<unnamed>' panicked at 'could not create cargo workspace: ChainedError { error: failed to read `/tmp/boo/src/Cargo.toml`, cause: No such file or directory (os error 2) }', /checkout/src/libcore/result.rs:859
note: Run with `RUST_BACKTRACE=1` for a backtrace.
thread '<unnamed>' panicked at 'could not create cargo workspace: ChainedError { error: failed to read `/tmp/boo/src/Cargo.toml`, cause: No such file or directory (os error 2) }', /checkout/src/libcore/result.rs:859 

I not undernstad, why emacs+rls open Cargo.toml in src, while it should look it at /tmp/boo/Cargo.toml?

Discussion: How to add support for Java language server

I am tying to add support for java language server eclipse.jdt.ls which is used in VS Code.

I changed lsp-mode.el and added these code similar to haskell-mode.

(lsp-define-client 'java-mode "java" 'stdio #'lsp--java-get-root
                   :command '("java" "-Declipse.application=org.eclipse.jdt.ls.core.id1"
                              "-Dosgi.bundles.defaultStartLevel=4"
                              "-Declipse.product=org.eclipse.jdt.ls.core.product"
                              "-Dlog.protocol=true"
                              "-Dlog.level=ALL"
                              "-noverify"
                              "-Xmx1G"
                              "-jar"
                              "/Users/tutysara/.vscode/extensions/redhat.java-0.1.0/server/plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar"
                              "-configuration"
                              "/Users/tutysara/.vscode/extensions/redhat.java-0.1.0/server/config_mac"
                              "-data"
                              "/Users/tutysara/src/myprojects/java/restful/simple-service")
                   :name "Java Language Server")

and

(defun lsp--java-get-root ()
  (let ((dir default-directory))
    (message "getting java root")
    (if (string= dir "/")
        (user-error "Couldn't find java root")
      dir)))

I have the hardcoded values for the path to start with.
I made these change to lsp-mode.el and evaluated the buffer.

When I switch to a java file and enable java-mode, nothing happens.

Is there any additional setup that I have to make.

type at point?

Sometimes I just want to see the type at point.

textDocument/hover will provide this information if the element is undocumented. If it has lots of documentation, this is lost in the gutter.

If possible I would like an interactive method to:

  1. allow keybindings to call when I want (as a longtime merlin user, C-c C-t is bound in muscle memory to give me the type of some variable/function in OCaml)
  2. only receive the variable/field/function/whatever's type at the current point.

Layering again.

The server can send some request messages to the client.

I have extended the lsp-receive module to do this, but have hit a problem where the applyEdit message needs to call a function from lsp-methods.

See alanz@b7baa87#diff-ab15cf2583b4dcc5d051aa007da57b4aR101

I am not sure what the right rearrangement is to solve this.

  • Introduce a new module similar to lsp-notifications and move stuff to it
  • Pass some sort of callback handler into the receive parser from lsp-methods
  • Move the entire contents of lsp-receive into lsp-methods. One file to rule them all.

can't jump into std

I can't seem to jump into std::io::Cursor for example.

Previously, racer needed to know about the source directory location; how can I tell lsp-mode the same (assuming I can or need to?)

Need a timeout on server replies

At the moment the emacs UI hangs for as long as the server is processing a message.

This should preferable become async, or should have some means to interrupt, or timeout.

Cleanup lsp--cur-workspace check

Instead of

  (unless lsp--cur-workspace
    (user-error "No language server is associated with this buffer"))

appearing at the start of most functions, perhaps introduce a in-lsp-workspace function that will only do its action if in a workspace, giving the warning otherwise.

Invalid options for slot range in lsp-diagnostic

When trying to use global-lsp-mode with the Rust language server, the mode fails with:

Eager macro-expansion failure: (error "Invalid options for slot range in lsp-diagnostic")
Invalid options for slot range in lsp-diagnostic

add `lsp-restart`

It would kill the current lsp if any is running, and restart a new one (without query).

This is useful for debugging, etc.

rename references?

Is there support planned for a rename references M-x command or allow to keybind?

flycheck help please

@vibhavp : which specific language server are you developing the flycheck stuff against?

I want to see a working version to compare for debugging my haskell one.

flycheck setup

Using

(add-to-list 'load-path "<path to emacs-lsp>")
(require 'lsp-mode)
(global-lsp-mode t)
(with-eval-after-load 'lsp-mode
    (require 'lsp-flycheck)
    (lsp-flycheck-setup))

in my dotspacemacs/user-config I get the following in the Messages buffer on startup:

(Spacemacs) Error in dotspacemacs/user-config: Symbol’s function definition is void: lsp-flycheck-setup

Toggling the lsp-mode does not actually toggle the server

If lsp-mode was active, doing M-x lsp-mode (toggle off) M-x lsp-mode (toggle on again) doesn't try to stop and then start the server again.

As a result of this, if the server for some reason dies, it is not possible to restart it in the current project unless you restart emacs or muck with variables.

Not providing autocompletion with the Rust Language Server

I am unsure as to whether this is an issue with the RLS itself or emacs-lsp (or perhaps even my own configuration), but I figured I would try here.
Environment variables are set, analysis data for the standard libraries have been installed, and racer works just fine on its own. However, when using the Rust Language Server in conjunction with emacs-lsp, autocompletion does not work. Other features such as goto-def and renaming are working though.

I have tried this using Emacs 25.1 and 26.0, running on Ubuntu.

Any idea of what could be causing this?

Invoking lsp-capabilities produces an error

Hi, I believe I found a bug. After setting up emacs-lsp and the Rust Language Server I invoked the function lsp-capabilities and received this error: Wrong type argument: listp, "Send full contents".

Invoking the same function on an emacs -Q with debug-on-error enabled produces the following output:

Debugger entered--Lisp error: (wrong-type-argument listp "Send full contents")
  car("Send full contents")
  (concat ": " (car (cdr (assoc value type))))
  (cond ((listp type) (concat ": " (car (cdr (assoc value type))))))
  (concat desc (cond ((listp type) (concat ": " (car (cdr (assoc value type)))))) "\n")
  (progn (concat desc (cond ((listp type) (concat ": " (car (cdr (assoc value type)))))) "\n"))
  (if (and elem desc type value) (progn (concat desc (cond ((listp type) (concat ": " (car (cdr ...))))) "\n")))
  (let* ((elem (assoc cap lsp--capabilities)) (desc (car (cdr elem))) (type (cdr (cdr elem))) (value (gethash cap (lsp--server-capabilities)))) (if (and elem desc type value) (progn (concat desc (cond ((listp type) (concat ": " (car ...)))) "\n"))))
  lsp--cap-str("textDocumentSync")
  mapconcat(lsp--cap-str ("textDocumentSync" "hoverProvider" "completionProvider" "signatureHelpProvider" "definitionProvider" "referencesProvider" "documentHighlightProvider" "documentSymbolProvider" "workspaceSymbolProvider" "codeActionProvider" "documentFormattingProvider" "documentRangeFormattingProvider" "renameProvider") "")
  (let ((str (mapconcat (function lsp--cap-str) (reverse (hash-table-keys (lsp--server-capabilities))) ""))) (save-current-buffer (set-buffer (get-buffer-create "lsp-capabilities")) (view-mode -1) (erase-buffer) (insert str) (view-mode 1)) (switch-to-buffer "lsp-capabilities"))
  lsp-capabilities()
  funcall-interactively(lsp-capabilities)
  call-interactively(lsp-capabilities record nil)
  command-execute(lsp-capabilities record)
  execute-extended-command(nil "lsp-capabilities" "lsp-ca")
  funcall-interactively(execute-extended-command nil "lsp-capabilities" "lsp-ca")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

I am running GNU Emacs 25.1.1 on Arch Linux.

how to test/use features

Navigating to a rust source file, asks me if i want to start a new language server, Y, language server correctly started, and appears to start an emacs process.

However, I don't see any lsp M-x functions besides lsp-capabilities, which states:

The server provides file formatting: Yes
The server provides project symbol support: Yes
The server provides file symbol support: Yes
The server provides references support: Yes
The server provides goto definition support: Yes
The server provides completion support: Yes
The server provides hover support: Yes
Document sync method: Send full contents

so:

  1. What do I need to "play" with the language server? For instance, how do i file format? how does hover support work? completion seems to not use my company backend? what is reference support, etc.?
  2. is goto-definition same as racer's M-. ? etc., how does this all tie in?
  3. might want to add a restart language server in M-x, as well as some other functions, like M-x lsp-complete-at-point, M-x lsp-hover-at-point for testing/debugging

Thanks, and keep up the good work!

Wrong type argument: `hash-table-p, nil` when using the rust langauge server

Hi,
I'm having trouble getting lsp-mode to work with the rust language server.
When it tries to get the completion items I get the following error:

{"jsonrpc":"2.0","method":"textDocument/completion","params":{"textDocument":{"uri":"file:///home/VKM/thomson/Source/thomson/snap-to-road-realdata/src/main.rs"},"position":{"line":29,"character":13}},"id":6} Output from language server: {"jsonrpc":"2.0","id":6,"result":[]} lsp--stdio-send-sync: Content-Length: 207 {"jsonrpc":"2.0","method":"textDocument/completion","params":{"textDocument":{"uri":"file:///home/VKM/thomson/Source/thomson/snap-to-road-realdata/src/main.rs"},"position":{"line":29,"character":13}},"id":7} Output from language server: {"jsonrpc":"2.0","id":7,"result":[]} completion--some: Wrong type argument: hash-table-p, nil

Full io log can be found here: https://gist.github.com/skeleten/36c3caae13fdcd2fcdc2817877bac067

Parser rewrite

The parser in lsp-receive.el needs to be rewritten to avoid hangups due to it sometimes failing to parse output from the language server.

how to use particular mode from git

Trying to test this, I've noticed the clients are separate repos, yet it isn't obvious to me how to use a particular language server client now; do we need to clone in the subdirectory, add it to new load path in .emacs, etc.?

completion missing for some items?

Sorry if this is dumb just testing stuff, but:

I can't seem to get method completion working for sample project:

screenshot from 2017-01-18 20-44-38

I would expect completion for String:: or Request:: to give a list of
available methods like the request field example does, e.g:

screenshot from 2017-01-18 20-43-58

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.