Code Monkey home page Code Monkey logo

lsp-snippet's People

Contributors

axelknock avatar svaante avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

axelknock

lsp-snippet's Issues

LSP-mode changed the way to check for yasnippet

Since emacs-lsp/lsp-mode#4413, lsp-mode does not check via featurep anymore but (fboundp 'yas-minor-mode).
Thus, lsp-snippet-tempel-lsp-mode-init would need to provide the minor mode instead.

I have asked at lsp-mode here if they would consider to allow other snippet expansion libraries, which would make the integration simpler.

Support for multiple placeholders with same content and indentations according to mode

Hi, I'm trying to use this package to make TempEL work with Eglot. But I found a few problems when I use texlab (an LSP implementation for LaTeX).

The first problem is that the same placeholder appears multiple times cannot be entered simultaneously. For example, to input something like this (from TempEL's readme), when the cursor is at \begin{ | }, the inputted text (enumerate) is expected to appear at \end{ | } at the same time. But it does not, and I have to input the same text twice. It seems that the placeholder are treated as two independent ones.

The second is that indentations are expanded as tabs. I suspect this is caused by an improperly implementation of LSP server because this phenomenon doesn't occurs when using clangd (an LSP implementation for C/C++). I'm not sure about this because I don't know much about LSP. But would you please try to convert tabs to indentations according to mode (like > in the tempo syntax)?

Thank you for your work!

malformed string with gopls

Hello, I've been using lsp-snippet (for tempel) with rust for some time and everything seem to work fine with their LSP server. I had to edit a go project and I've decided to try it with gopls. The server seems to produce an invalid str format for lsp-snippet.

small reproducible case

package main

import (
	"fmt"
)

func main() {


// Complete with Println
	fmt.Print 
}

The server return the following

Possible malformed snippet "Println${1:}"

The following added test produce the same error.

  (should
   (equal (lsp-snippet-parse "${1:}")
          '((tabstop 1))))

Snippet expansion can contain unwanted backslash

Hey there,

thanks a lot for this package! So far it has been working pretty well.

One small issue I have encountered when I use it with Bash LSP is that for some snippets, there are dangling \$, for example

(lsp-snippet-parse "\\${${1:variable}:-${2:default}}")

should result in ${variable:-default} but is \${variable:-default}. In Bash (and other shells) this can actually cause issues because this would disable the expansion in Bash, e.g.

foo=1

echo "${foo}" # -> result is 1
echo "\${foo}" # -> result is ${foo}

I found the original snippet here.

Update 1:

I was looking through the source and trying to understand what is happening (I am not sure if I understand it correctly) and maybe this is a bit more complicated.

  1. I think the observed behavior is correct for yasnippet but not for tempel. The documentation of yasnippet says

Arbitrary text can be included as the content of a template. They are usually interpreted as plain text, except $ and ```. You need to use \ to escape them: `$` and ```. The `\` itself may also needed to be escaped as `\\` sometimes.

I think Tempel does not have that issue.

  1. I think the current logic is like this: If we encounter a backslash, take it plus the following character. But I think for Tempel it needs to be: If we encounter a backslash, ignore it and take whatever character comes next.
    In theory, there could be snippets like
"\\$\\\\$\\\\"  would need to parse to "$\$\"

Update 2:

I have created a clumsy patch which seems to solve the issue for Tempel.

@@ -141,16 +141,24 @@
 
 (defun lsp-snippet--escaped-string-to (stop-at)
   (let ((start (lsp-snippet--index))
-        (continue t))
+        (continue t)
+        ;; Output string
+        (result ""))
     (while continue
       ;; Skip next token if `backslash'
       (when (lsp-snippet--take '(backslash))
         ;; Skip next token
-        (lsp-snippet--ignore '(eof)))
+        (lsp-snippet--ignore '(eof))
+        ;; Add the character following the backslash and ignore the backslash itself
+        (setq result (concat result (substring lsp-snippet--str (1+ start) (lsp-snippet--index))))
+        (setq start (lsp-snippet--index)))
       (setq continue (lsp-snippet--ignore
-                      `(eof . ,stop-at))))
-    (unless (eq start (lsp-snippet--index))
-      (substring lsp-snippet--str start (lsp-snippet--index)))))
+                      `(eof . ,stop-at)))
+      ;; Add to result
+      (setq result (concat result (substring lsp-snippet--str start (lsp-snippet--index))))
+      (setq start (lsp-snippet--index)))
+    (when (length> result 0)
+      result)))

rust-analyzer: no space after placeholder

See this:
Screenshot from 2023-12-19 at 17_47_53 149043922

There is supposed to be a space between the first placeholder and the equal sign, and between the second placeholder and the opening brace (yasnippet does this correctly)

Sorry if this is hard to reproduce with other servers, r-a is the only one I use which provides space-after-placeholder snippets

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.