This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-22
Channels
- # announcements (7)
- # babashka (1)
- # beginners (87)
- # boot (1)
- # cider (1)
- # clj-kondo (33)
- # cljfx (1)
- # cljs-dev (8)
- # clojars (3)
- # clojure (105)
- # clojure-austin (3)
- # clojure-europe (74)
- # clojure-finland (1)
- # clojure-korea (4)
- # clojure-nl (1)
- # clojure-uk (6)
- # clojurescript (10)
- # conjure (9)
- # cursive (29)
- # datalog (6)
- # datomic (13)
- # emacs (3)
- # events (4)
- # figwheel-main (1)
- # gratitude (1)
- # humbleui (6)
- # introduce-yourself (7)
- # jackdaw (1)
- # jobs (1)
- # lsp (29)
- # malli (3)
- # nbb (2)
- # podcasts-discuss (1)
- # portal (5)
- # re-frame (4)
- # reitit (28)
- # remote-jobs (5)
- # shadow-cljs (38)
- # tools-deps (46)
- # vim (6)
- # xtdb (24)
Using Lua (or fennel) for Neovim 0.7.0, I am trying to change the Clojure FileType commentstring
to be ;;
rather than what seems to be the default ;
commentstring. Or at the very least have both ;
and ;;
recognised as a comment line.
I’d like to use vim-commentry, or something similar to toggle comment lines, but it only recognises ;
lines, so actually adds a third ;
if I try to uncomment an existing line with ;;
All my code is written with ;;
as are my work colleagues, so changing all the comments is not a workable option…
I am still learning Neovim and Lua (and fenel - that seems to be the easy bit), so assume I know nothing 🙂
To change the comment string in vimscript seems to be
augroup commentary_config
autocmd!
autocmd FileType lisp,clojure,racket setlocal commentstring=;;\ %s
augroup END
But I dont know how to do this in Lua with Neovim…something like this in fennel
(vim.api.nvim_create_autocmd
:FileType
{:group (vim.api.nvim_create_augroup :commentary_config {:clear true})
:pattern [:lisp :clojure :racket]
:callback (fn [] (set vim.opt_local.commentstring ";; %s") nil)})
But I am not sure in which version of neovim those api calls where introducedThis is very common in my config, so I've created a macro https://github.com/nbardiuk/dotfiles/blob/fc61451baa1df5d03d2e59c1dd3b5151915b760d/nix/.config/nixpkgs/home/init.fnl#L21-L26
(au commentary_config :FileType [:lisp :clojure :racket]
(set vim.opt_local.commentstring ";; %s"))
Excellent, I’ve tried the first code block you shared and it works perfectly. I’ll have a look at your dot files and if there are more autocmd things I need then I’ll adopt the macro you have written. The whole config you have shared looks very interesting, so I will spend some time looking through it to learn more about Neovim and fennel Thank you very much for sharing.