Fork me on GitHub
#vim
<
2023-08-30
>
mx200017:08:42

I want to see just the defined vars in a namespace in a list, I think counterclockwise had this long time ago. How do I do this? using macvim and vim-fireplace

dave17:08:16

clojure.core has a function for this, ns-publics Example usage:

;; list of vars in current namespace
(ns-publics *ns*)

;; list of vars in another namespace
(ns-publics 'clojure.string)
I'm not sure if fireplace has anything built-in for this, but you could eval a form like that in your REPL session

mx200017:08:05

Hey, I know about this function. I want to have listview like vim nerdtree plugin which lists all vars with jump too

dave17:08:40

Ah, I see. LSP provides functionality like that. I use Neovim, so I don't know specifically how to set it up in regular Vim, but there ought to be a way!

mx200017:08:58

What's lsp?

dave17:08:16

Language Server Protocol. It's a feature built into a lot of editors nowadays. The idea is that you have language servers for specific languages (Clojure has one called clojure-lsp) and they work in any editor that supports LSP. On the other side, you have LSP clients that are built into a bunch of different editors, and they support any language that has a language server.

dave17:08:40

I just remembered a plugin that I used to use that I enjoyed - it might help you here: https://github.com/liuchengxu/vista.vim

dave17:08:29

Back when I used it, it didn't support LSP, it was based on ctags instead. Looks like nowadays, it supports LSP, which is great

dave17:08:11

An advantage of doing this via LSP is that it will always work, even if you don't have a REPL running.

practicalli-johnny20:08:32

Clojure LSP client suggestions for Vim (don't forget to install clojure-lsp server) https://clojure-lsp.io/clients/#vim Note that not all LSP clients will support all LSP features

marrs10:08:55

Fair warning: I've not been satisfied with any of the LSP clients for Vim. They're slow and flaky. If I have to use the LSP then I run Neovim; its built-in client is pretty sound.

marrs10:08:23

> I want to have listview like vim nerdtree plugin which lists all vars with jump too @U0ALH6R89 Sounds like you want to populate a quickfix list. It might be possible for vim-fireplace to pipe its eval output to other commands. The :Last command will output the result of the last eval to a preview buffer. Perhaps that can be converted to a quickfix list?

kawas13:08:54

If you use tags there may be a way to show a window with current file tags and get defined variables :thinking_face:

mx200013:08:55

Strange, shouldn't this be included

dave14:08:48

Neovim's built-in LSP is 💯

dave15:08:40

That plugin I posted above, vista.vim, works with ctags as well, if you don't want to take the plunge and set up LSP

👍 2
dave15:08:03

But my recommendation would be to set up LSP, because it's amazing.

mx200015:08:25

I need neovim for that?

dave15:08:33

No, there are LSP client plugins for regular Vim too.

dave15:08:59

Oh, you mean vista? No, that works in both Neovim and not-Neovim (Oldvim?)