Code Monkey home page Code Monkey logo

consult-lsp's Introduction

Gerry Agbobada

I'm a backend software engineer currently working at Tsuga, and this is my github profile. I mostly like Rust and Schemes, but I have good experience in C++ and Python as well, trying to embed the languages I like working with inside the ones I like hacking with. That makes Rust and Web Assembly really nice technologies to explore!

Sometimes, I blog. It is quite rare though.

Nowadays I mostly use my github profile to contribute to Emacs ecosystem through Doom or packages like consult-lsp and a converter from org to tree-sitter test.

I think my most fun projects are:

  • Xile: draft of a front-end for Xi editor, written in Guile Scheme
  • R7.rs: a Rust hosted R7RS scheme (WIP, and interpreter only for now)
  • tree-sitter-org: a tentative to make a tree-sitter grammar for org-mode syntax. Currently it's in a "waiting" state until org grammar is a little clarified

I am also getting my feet wet with front-development with my fork of Rustpad which adds integration with Piston for shared remote code execution. It is currently hosted live on pad.gagbo.net.

Metrics

gagbo's github stats

Mastodon profile

consult-lsp's People

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

Watchers

 avatar  avatar

consult-lsp's Issues

Diagnostics are randomly sorted by severity

Hi 👋 I'm using consult-lsp everyday. Thank you for sharing it!

It looks like consult-lsp tries to sort flatten diagnostics by severity. So the order would be: error, warning, info and hints. But in the README pic, it's warning, eror and then hints. So the sort might not be working as expected.

On my computer, the order often changes and here's an example:

diags

And another after meaningless change and saving:

diag-2

consult-lsp-file-symbols not grouping by symbol kind

I'm having trouble getting consult-lsp-file-symbols to group symbol results by their kind. I have a fairly standard installation of consult-lsp:

(use-package consult-lsp
  :custom
  (consult-lsp-marginalia-mode t))

By default, consult-lsp-symbols groups symbol results by their kind but consult-lsp-file-symbols displays its results ungrouped as shown in the screenshot below. Is this expected behavior or am I missing something? Ideally, I'd like to achieve a similar result as is shown in the screenshots in the project's README. This ungrouped behavior happens whether or not I enable Marginalia integration. I have not customized consult-lsp-symbols-narrow in any way.

Version information:
Emacs: 28.0.60
rust-analyzer: 2022-01-03
consult-lsp: latest

Screen Shot 2022-01-04 at 10 48 14 am

"consult--position-marker" has renamed

Hi,
3 days ago minad renamed consult--position-marker to consult--marker-from-line-column, in melpa's 'consult' package. This refactoring broke consult-lsp.
Perhaps it would be better to put a copy in consult-lsp? This function is simple and has no dependency on consult functions.
Thank you.

Is there a way to filter the results?

When I run consult-lsp-symbols I see system methods/class due to the way C++ include's works (I suppose). I'd like to filter those by checking if source files belong to the project. I've checked annotate functions but I do not think they provide the functionality.

I am not sure how much of the work is being done by LSP server, emacs-lsp, consult and this package. Feel free to close this, if it cannot be done at this level easily.

no modes enabled when a file is previewed upon calling `consult-lsp-diagnostics`

Bug description

I found out an odd behaviour and I don't know if it is expected or, on the other case, it should be categorized as a bug.

When running consult-lsp-diagnostics, it shows all errors reported by the lsp server; moving down between such errors, a preview of the file is loaded and the cursor is focused on the error. These preview doest not load any mode, neither column numbers, so flycheck starts checking with other checkers (like gofmt, etc) instead of lsp (which is normal because the lsp-mode is not actived yet); it causes the icon of the flycheck in the modeline reports a different number of errors when previewed than loaded.

Example

An example that clarifies better the above explanation. When calling consult-lsp-diagnostics and selecting a file that has not been loaded previously, flycheck starts running during the preview of such file and reports no errors (it can be seen in the modeline) because one of the linters has failed.

Screenshot 2022-08-24 at 17 50 50

Once the same file is loaded into a buffer, flycheck runs again but this time, the checker is lsp because the mode lsp has been enabled. Now, flycheck reports errors.

Screenshot 2022-08-24 at 17 51 04

The preview should either activate lsp or avoid activating any other packages (e. g. flycheck), shouldn't it? If possible both options, I would prefer to enable modes when a file is previewed instead of avoiding activating other packages.

Also, I found that the errors reported by consult-lsp-diagnostics and lsp-treemacs-error-list are not equal. The first one reports 71 errors and the second one 123 errors. Shouldn't they bring from lsp the same value?

Screenshot 2022-08-24 at 18 21 16

Screenshot 2022-08-24 at 18 35 50

Screenshot 2022-08-24 at 18 21 05

Problems with rng-uri-file-name

This function is required neither by lsp nor consult so without explicitly loading it, Emacs complains about an unknown function. After loading rng-uri.el, the function will emit error when used with C++ server. The reason for that is that standard library headers are placed on Linux in /usr/include/c++/<version> and the input for rng-uri-file-name will be e.g. file:///usr/include/c%2B%2B/10.2.0/vector. The presence of %2B for some reason makes this regex non-matching.

Slowness when using for Clojure

Hi, I really like consult-lsp-symbols but I can't use it with most projects I work, even medium/small projects because of Emacs freezing and taking too long to return the symbols.

One good repo to test is the clojure-lsp repo itself and if we check server logs we can see the server is pretty fast
image

I wonder if there is any quick wins for performance in consult-lsp side

Preview overlays stick around when quitting from consult-lsp-diagnostics

The consult-preview-line and consult-preview-cursor overlays stick around when quitting C-g out of consult-lsp-diagnostics

Steps to reproduce:

  1. Have a file with at least 1 diagnosed error/warning by the corresponding lsp-server, like in python
def f(x):
    Pass
  1. Call M-x consult-lsp-diagnostics and cycle through some candidates
  2. Hit C-g and the last preview overlays stick around

Tested on (recent) emacs 28, consult-lsp 8ed43c6

`nil` column in consult-lsp-symbols

The nil column is showing container-name info from SymbolInfo, and I thought it'd be relevant information to have, but apparently, neither Rust Analyzer, CCLS, clangd, metals, nor HLS is giving information in that field, so consult-lsp--symbols--transformer needs to be changed to remove the useless column

consult--tofu-encode error when invoking consult-lsp-file-symbols

Backtrace:

Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p consult--type)
  consult--tofu-encode(consult--type)
  consult--location-candidate(#("APlayerCharacter (APlayerCharacter::APlayerCharact..." 0 16 (face lsp-face-semhl-class)) #<marker at 434 in PlayerCharacter.cpp> 12 consult--type (111 . "Other") consult--name "APlayerCharacter::APlayerCharacter" consult--details "()")
  consult-lsp--file-symbols--transformer(#<hash-table equal 5/5 0xa7556b25cd>)
  mapcar(consult-lsp--file-symbols--transformer (#<hash-table equal 5/5 0xa7556b25cd> #<hash-table equal 5/5 0xa7556b3445> #<hash-table equal 5/5 0xa7556b36a5> #<hash-table equal 5/5 0xa7556b3911> #<hash-table equal 5/5 0xa7556b3b71> #<hash-table equal 5/5 0xa755995a41> #<hash-table equal 5/5 0xa75564e839> #<hash-table equal 5/5 0xa75564ea91> #<hash-table equal 5/5 0xa755652539> #<hash-table equal 5/5 0xa755652799>))
  consult-lsp--file-symbols-candidates()
  consult-lsp-file-symbols(nil)
  funcall-interactively(consult-lsp-file-symbols nil)
  call-interactively(consult-lsp-file-symbols record nil)
  command-execute(consult-lsp-file-symbols record)
  execute-extended-command(nil "consult-lsp-file-symbols" "consult lsp")
  funcall-interactively(execute-extended-command nil "consult-lsp-file-symbols" "consult lsp")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

Error when invoke consult-lsp-file-symbol

Debugger entered--Lisp error: (wrong-type-argument symbolp "children")
  lsp-keyword->string("children")
  lsp-get(#<hash-table equal 5/5 0xa0f26ba87d> "children")
  #f(compiled-function (to-flatten accumulator) #<bytecode 0xd01f83952c47062>)((#<hash-table equal 5/5 0xa0f26ba87d> #<hash-table equal 5/5 0xa0f26b8ecd> #<hash-table equal 5/5 0xa0f26b912d> #<hash-table equal 5/5 0xa0f2857581> #<hash-table equal 5/5 0xa0f28577e1> #<hash-table equal 5/5 0xa0f2856639> #<hash-table equal 5/5 0xa0f28570b5> #<hash-table equal 5/5 0xa0f285730d> #<hash-table equal 5/5 0xa0f2856165> #<hash-table equal 5/5 0xa0f28563c5> #<hash-table equal 5/5 0xa0f2859e69> #<hash-table equal 5/5 0xa0f28598dd> #<hash-table equal 6/6 0xa0f2859b31> #<hash-table equal 6/6 0xa0f285a349> #<hash-table equal 6/6 0xa0f28590f5> #<hash-table equal 6/6 0xa0f28f271d> #<hash-table equal 6/6 0xa0f28f4f99> #<hash-table equal 6/6 0xa0f28a4f41> #<hash-table equal 6/6 0xa0f21b86b1> #<hash-table equal 6/6 0xa0f2547df5> #<hash-table equal 6/6 0xa0f274c221> #<hash-table equal 6/6 0xa0f274cf3d> #<hash-table equal 6/6 0xa0f23b4c45> #<hash-table equal 6/6 0xa0f23b77e1> #<hash-table equal 6/6 0xa0f27ad38d> #<hash-table equal 6/6 0xa0f2743b35> #<hash-table equal 6/6 0xa0f2744ec1> #<hash-table equal 6/6 0xa0f2b89271> #<hash-table equal 6/6 0xa0f2b5b925> #<hash-table equal 6/6 0xa0f2b5da55> #<hash-table equal 6/6 0xa0f2b60dfd> #<hash-table equal 6/6 0xa0f2b62ef5> #<hash-table equal 6/6 0xa0f2b627c1> #<hash-table equal 5/5 0xa0f2b67c3d> #<hash-table equal 6/6 0xa0f2b67ea9> #<hash-table equal 6/6 0xa0f2b66431> #<hash-table equal 6/6 0xa0f2900d5d> #<hash-table equal 6/6 0xa0f28ffa1d> #<hash-table equal 6/6 0xa0f2901f15> #<hash-table equal 6/6 0xa0f2900641> #<hash-table equal 6/6 0xa0f2900b1d> #<hash-table equal 5/5 0xa0f2902c11> #<hash-table equal 5/5 0xa0f2902679> #<hash-table equal 5/5 0xa0f29030f1> #<hash-table equal 5/5 0xa0f2903351> #<hash-table equal 5/5 0xa0f29039c1> #<hash-table equal 5/5 0xa0f2903c21> #<hash-table equal 5/5 0xa0f2902e81> #<hash-table equal 5/5 0xa0f2905111> #<hash-table equal 5/5 0xa0f2905371> ...) nil)
  consult-lsp--flatten-document-symbols((#<hash-table equal 5/5 0xa0f26ba87d> #<hash-table equal 5/5 0xa0f26b8ecd> #<hash-table equal 5/5 0xa0f26b912d> #<hash-table equal 5/5 0xa0f2857581> #<hash-table equal 5/5 0xa0f28577e1> #<hash-table equal 5/5 0xa0f2856639> #<hash-table equal 5/5 0xa0f28570b5> #<hash-table equal 5/5 0xa0f285730d> #<hash-table equal 5/5 0xa0f2856165> #<hash-table equal 5/5 0xa0f28563c5> #<hash-table equal 5/5 0xa0f2859e69> #<hash-table equal 5/5 0xa0f28598dd> #<hash-table equal 6/6 0xa0f2859b31> #<hash-table equal 6/6 0xa0f285a349> #<hash-table equal 6/6 0xa0f28590f5> #<hash-table equal 6/6 0xa0f28f271d> #<hash-table equal 6/6 0xa0f28f4f99> #<hash-table equal 6/6 0xa0f28a4f41> #<hash-table equal 6/6 0xa0f21b86b1> #<hash-table equal 6/6 0xa0f2547df5> #<hash-table equal 6/6 0xa0f274c221> #<hash-table equal 6/6 0xa0f274cf3d> #<hash-table equal 6/6 0xa0f23b4c45> #<hash-table equal 6/6 0xa0f23b77e1> #<hash-table equal 6/6 0xa0f27ad38d> #<hash-table equal 6/6 0xa0f2743b35> #<hash-table equal 6/6 0xa0f2744ec1> #<hash-table equal 6/6 0xa0f2b89271> #<hash-table equal 6/6 0xa0f2b5b925> #<hash-table equal 6/6 0xa0f2b5da55> #<hash-table equal 6/6 0xa0f2b60dfd> #<hash-table equal 6/6 0xa0f2b62ef5> #<hash-table equal 6/6 0xa0f2b627c1> #<hash-table equal 5/5 0xa0f2b67c3d> #<hash-table equal 6/6 0xa0f2b67ea9> #<hash-table equal 6/6 0xa0f2b66431> #<hash-table equal 6/6 0xa0f2900d5d> #<hash-table equal 6/6 0xa0f28ffa1d> #<hash-table equal 6/6 0xa0f2901f15> #<hash-table equal 6/6 0xa0f2900641> #<hash-table equal 6/6 0xa0f2900b1d> #<hash-table equal 5/5 0xa0f2902c11> #<hash-table equal 5/5 0xa0f2902679> #<hash-table equal 5/5 0xa0f29030f1> #<hash-table equal 5/5 0xa0f2903351> #<hash-table equal 5/5 0xa0f29039c1> #<hash-table equal 5/5 0xa0f2903c21> #<hash-table equal 5/5 0xa0f2902e81> #<hash-table equal 5/5 0xa0f2905111> #<hash-table equal 5/5 0xa0f2905371> ...))
  consult-lsp--file-symbols-candidates()
  consult-lsp-file-symbols(nil)
  funcall-interactively(consult-lsp-file-symbols nil)
  command-execute(consult-lsp-file-symbols record)
  execute-extended-command(nil "consult-lsp-file-symbols" "consult lsp file symbols")
  funcall-interactively(execute-extended-command nil "consult-lsp-file-symbols" "consult lsp file symbols")
  command-execute(execute-extended-command)

consult-lsp version is 20221019. lsp-mode version is 20221030. lsp server is clangd.

Is this an upstream bug?

Quick review

Hi Gerry,

I went over your consult-lsp code. Here are a few comments, mostly pretty minor nitpicks. I think this looks good already, but I have not tried it yet. Did you have some more issues you want to discuss, in particular regarding the Consult APIs?

Daniel


  • Naming convention - consult-lsp-- is probably better than consult-lsp-diagnostics--. But I've seen you organized everything under the consult-lsp-diagnostics-- and consult-lsp-symbols-- namespace, maybe that's okay?

(defun consult-lsp-diagnostics--flatten-diagnostics (transformer &optional current-workspace?)

  • Use pcase for this? Alternatively use an alist to keep the infor for both consult-lsp-diagnostics--severity-to-level and consult-lsp-diagnostics--severity-to-type?

(cond ((= sev 1) (propertize "error" 'face 'error))
((= sev 2) (propertize "warn" 'face 'warning))
((= sev 3) (propertize "info" 'face 'success))
((= sev 4) (propertize "hint" 'face 'italic))
(t "unknown"))))

  • Use rassq on consult-lsp-symbols--narrow instead?

(defun consult-lsp-symbols--kind-to-narrow (symbol-info)

  • The :predicate is unnecessary. consult--type-narrow already supplies a special narrowing predicate, which is only used when consult--narrow is non-nil.

consult-lsp/consult-lsp.el

Lines 322 to 327 in 04462d2

:predicate
(lambda (cand)
(let ((key (get-text-property 0 'consult--type cand)))
(if consult--narrow
(= key consult--narrow)
t)))

consult-lsp/consult-lsp.el

Lines 144 to 149 in 04462d2

:predicate
(lambda (cand)
(let ((key (get-text-property 0 'consult--type cand)))
(if consult--narrow
(= key consult--narrow)
t)))

Break lines

Hey, is it possible to somehow break the line from a message? I mean, I can only see parts of the message and the rest is truncated. Is there maybe an option that I could enable?

How large is the minibuffer window by default?

This is just a sort-of personal question (which could be relevant to others), so you can close this immediately in case you want to.

I have the following problem. I use vertico with doom emacs and all other consult commands I use take up ca. 1/3 of the screen:
screen_2022-03-20_12-00-46

To the contrary, consult-lsp-diagnostics can take up almost all of my screen:
screen_2022-03-20_11-58-12

So I wonder if you could help me limit this to 1/3 of the screen.

consult-lsp--file-symbols-candidates: No symbols

when I run consult-lsp-file-symbols, it showed no symbols. but I got right infos with consult-imenu.

image

consult-lsp-file-symbols has a big advantage to consult-imenu due to the narrowing mechanism. I really hope this command could run as expected. thx.

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.