svaante / lsp-snippet Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
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.
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!
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))))
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.
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.
"\\$\\\\$\\\\" 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)))
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.