This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-14
Channels
- # announcements (2)
- # aws (1)
- # babashka (18)
- # babashka-sci-dev (103)
- # beginners (165)
- # calva (51)
- # cider (8)
- # circleci (1)
- # clj-kondo (22)
- # clj-on-windows (2)
- # cljdoc (1)
- # cljfx (31)
- # cljs-dev (16)
- # clojure (81)
- # clojure-europe (71)
- # clojure-nl (7)
- # clojure-uk (11)
- # clojurescript (20)
- # code-reviews (26)
- # conjure (1)
- # contributions-welcome (1)
- # core-async (15)
- # cursive (8)
- # datomic (8)
- # defnpodcast (2)
- # eastwood (24)
- # emacs (10)
- # events (1)
- # fulcro (4)
- # funcool (31)
- # graalvm (43)
- # graphql (8)
- # honeysql (9)
- # introduce-yourself (1)
- # jobs (12)
- # kaocha (3)
- # lsp (28)
- # malli (4)
- # meander (4)
- # membrane (7)
- # off-topic (64)
- # other-languages (3)
- # pedestal (1)
- # polylith (31)
- # portal (5)
- # re-frame (4)
- # reitit (1)
- # releases (5)
- # rum (2)
- # schema (2)
- # sci (34)
- # shadow-cljs (21)
- # vscode (1)
Looking at the Clojure LSP built-in snippets, it seems Clojure code can be used to help generate the snippet. For example https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/feature/completion_snippet.clj#L26-L31 uses format
function.
Is there anything stopping this approach when defining :additional-snippets
for my own custom snippets?
I assume if Clojure code is included, it should be simple code for performance sake.
it's a valid idea but not sure would be easy to implement since the code is already compiled
the format on this built-in script being is calling during compilation, so it's not dynamic code being executed
if user provide custom clojure-code, how we would run that on a running clojure procces (specially graalvm one)
So if defn-
snipped was not buit-in, then the following snippet would not work
{:name "defn-"
:detail "Create private function"
:snippet (format "(defn%s ${1:name} [$2]\n ${0:body})"
(if (:use-metadata-for-privacy? settings)
" ^:private"
"-"))}
Ah, its because clojure-lsp is compiled by Graal... I forgot that 🙂
So if there was a useful case for including a bit of Clojure code, I should submit a PR to add a built-in snippet and then it would work (assuming the snippet pr is approved)
I think a feature to add custom clojure would be great, I just have no idea how we could achieve that 😅 , feel free to start with a issue where we can discuss the problem and ways to solve it
I'll try and think of some more snippets that would benefit from custom code. I'm just writing a blog and migrating my yasnippets snippets at the moment. I'll raise an issue later today. Thank you.
this looks nice. should this be working in vscode/calva? haven’t seen any of the snippets yet and they don’t show up in the “insert snippet” command we were talking about adding something similar into calva, but helping with LSP would make more sense if the “custom clojure” part can work out somehow
Clojure-lsp already have a lot of snippets via completion https://clojure-lsp.io/features/#snippets
yeah I just saw those for the first time. My question is: does this work in calva out of the box? it seems to be broken for me
so I’d just type in defn-
hit ctrl+space and should see a snippet in my autocompletions? than its broken.
2022-01-16T16:33:21.967Z DEBUG [clojure-lsp.server:?] - :codeAction 49ms
2022-01-16T16:33:27.329Z DEBUG [clojure-lsp.server:?] - :completion 171ms
2022-01-16T16:33:27.396Z DEBUG [clojure-lsp.server:?] - :resolveCompletionItem 42ms
the logs indicate it working i think, but there are no snippets in my completionsMaybe calva should opt-in something on vscode API? Not sure, maybe @U9A1RLFNV may know more about it
Double check if client(calva) send the the completionSnippet support: https://microsoft.github.io/language-server-protocol/specification#textDocument_completion
yeah maybe, I’ll look into it more. was just wondering if my install is broken or if it never worked
thank you, i’ll check
yeah there seems to be no integration for this in calva unless I’m blind, but I also checked in source. Am I missing something @U0ETXRFEW?
If there is anything about that integration with lsp, should be on lsp/main on calva IIRC
maybe there is a missing opt-in that need to be done on calva side, like adda supportSnippets somewhere via the VScode lsp api
@U02EMBDU2JU Feel free to create an issue for this. A PR is welcome too.
thanks @U9A1RLFNV, I’ll do that. just wanted to make sure its actually a missing link not a bug in something that should already work:)
puh finally got around to creating a ticket at least: https://github.com/BetterThanTomorrow/calva/issues/1483