Fork me on GitHub
#vim
<
2019-10-02
>
walterl01:10:10

is https://gist.github.com/xzj/1518834 the "Right Way" to add ctags support for Clojure? i'm asking here, since my end goal is to be able to use fzf.vim's BTags (or similar) for jumping to symbols in the current Clojure buffer. so the solution doesn't need to use ctags.

walterl01:10:40

it seems like that ~/.ctags works, but is limited: it doesn't support e.g. defprotocol and defrecord. while it's easy enough to add those statements, it makes me think that there should probably be a better solution/setup out there.

dave01:10:10

i think some of that clojure config may be part of universal ctags i do have some configuration similar to the link you've posted: https://github.com/daveyarwood/dotfiles/blob/master/ctags/clojure.ctags a lot of my config (maybe all of it?) is a hold-over from when i was using exuberant ctags before, so i'm not sure how much of that is still necessary

dave01:10:37

i too would be interested to know if there is a "canonical" way to do ctags with clojure

walterl02:10:31

have we moved on from exuberant-ctags? o_O

dave03:10:55

I think there is still good support for both in the vim ecosystem. One of the benefits of universal ctags is that more languages (including clojure) are supported out of the box

sogaiu04:10:45

latest universal ctags does not need any extra config for basic clojure iiuc. does anyone know differently?

sogaiu04:10:30

universal ctags does not use .ctags iiuc.

sogaiu05:10:02

> Universal-ctags doesn't load /.ctags and ./.ctags at starting up time. Instead, it loads /.ctags.d/.ctags and ./.ctags.d/.ctags. See the above web site and man pages (man/ctags.1.rst.in and man/ctags-incompatibilities.7.in in the source tree). via: https://github.com/universal-ctags/ctags#user-content-differences

dharrigan05:10:49

I use Exuberant Ctags and it has support for Clojure

dharrigan05:10:04

ctags --list-languages has Clojure in it's list.

dharrigan05:10:16

Then I use vim-gutentags to manage.

sogaiu05:10:15

would you mind posting some related links? i never had luck with exuberant ctags out-of-the-box (ended up mucking around with .ctags) -- i only found universal ctags to have clojure support built-in.

sogaiu05:10:52

you're an arch linux user, right? i'm using universal-ctags-git from aur.

dharrigan05:10:19

Hi, if I recall, I didn't do much. I simplly installed ctags, then installed the vim plugin

dharrigan05:10:09

If I open up a clojure file in vim, then a ctags file is created for me in the project root

sogaiu05:10:42

so you're using extra/ctags then?

dharrigan05:10:44

Then I installed vim Plug 'majutsushi/tagbar' to show me a nice tagbar

dharrigan05:10:35

I stand corrected, I use universal ctags

dharrigan05:10:50

% yay -Qi ctags
Name            : ctags
Version         : 1:r20190522+g3fdf28bc-1
Description     : Generates an index file of language objects found in source files
Architecture    : x86_64
URL             : 
Licenses        : GPL
Groups          : None
Provides        : universal-ctags
Depends On      : libxml2  jansson  libyaml  libseccomp
Optional Deps   : None
Required By     : None
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 1065.00 KiB
Packager        : Levente Polyak <[email protected]>
Build Date      : Wed 22 May 2019 22:51:22 BST
Install Date    : Thu 06 Jun 2019 11:25:26 BST
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature

sogaiu05:10:07

all these different versions had me pulling my hair out, so i was curious 🙂

dharrigan05:10:42

bbl - kid needs feeding 🙂

sogaiu05:10:22

thanks for mentioning vim-gutentags -- hope the feeding goes well 😉

walterl13:10:55

meh. i'm using ubuntu's exuberant-ctags: Version: 1:5.9~svn20110310-11! 😱

walterl13:10:36

its last official release is even older! > Version 5.8 [09 July 2009] -- http://ctags.sourceforge.net/

walterl13:10:26

no debian/ubuntu packages make universal-ctags hard to accept, though 😢

dharrigan19:10:24

@snoe trying to debug my coc-clojure not showing doc on hover, still the case. I've got trace on and I can see coc sending the uri along with position and line number, then following into the clojure-lsp code, I can see where the information is attempting to be gathered, but the result is like this:

dharrigan19:10:23

[Trace - 20:47:46] Sending request 'textDocument/hover - (3)'.
Params: {
    "textDocument": {
        "uri": "file:///home/foo/ojure/scratch/src/scratch/foobar.clj"
    },
    "position": {
        "line": 4,
        "character": 2
    }
}


[Trace - 20:47:46] Received response 'textDocument/hover - (3)' in 4ms.
Result: {
    "contents": {
        "kind": "markdown",
        "value": "
\nclojure.core/juxt\n
\n\n----\nlsp: :norename"
    },
    "range": {
        "start": {
            "line": 4,
            "character": 2
        },
        "end": {
            "line": 4,
            "character": 6
        }
    }
}

snoe19:10:31

Hrm, are you building from the repo? the homebrew formula is out of date. You can also try deleting the project's .lsp folder

dharrigan20:10:02

nope, using arch, using the release version of clojure-lsp

dharrigan20:10:35

deleted the .lsp, no joy

snoe20:10:53

Is this cljs or clj?

snoe20:10:38

Probably better to start a thread. I'll have to look into the release then. Can you try to clone the repo and launch it from lein like https://github.com/snoe/dotfiles/blob/master/home/.vim/coc-settings.json ?

dharrigan20:10:29

sure, will get back to you, thanks

dharrigan20:10:55

done, same result

snoe20:10:40

what version of clojure are you on?

snoe20:10:45

So I would expect to see an error about parsing clojure/core.clj in the /tmp/lsp.out startup

dharrigan20:10:39

% rm /tmp/lsp.out && tail -F /tmp/lsp.out
tail: cannot open '/tmp/lsp.out' for reading: No such file or directory
tail: '/tmp/lsp.out' has appeared;  following new file
INFO  clojure-lsp.main: Server started
INFO  clojure-lsp.main: ====== LSP nrepl server started on port 43811
WARN  clojure-lsp.main: Initialize
INFO  clojure-lsp.main: :initialize 183 ()
WARN  clojure-lsp.main: Initialized #object[org.eclipse.lsp4j.InitializedParams 0x5f41a282 InitializedParams [
]]
WARN  clojure-lsp.main: DidCloseTextDocumentParams
WARN  clojure-lsp.main: DidCloseTextDocumentParams

dharrigan20:10:13

tried on java 8 and java 12

snoe20:10:45

Can you delete the .lsp dir and get the startup? The classpath and other things are cached

dharrigan21:10:06

.lsp deleted, same issue

snoe21:10:09

is your project using lein? can you run lein classpath ?

dharrigan21:10:59

I'll get the classpath for you, but I'll ping you privately 🙂

snoe21:10:58

that's ok, the problem is I don't support deps.edn 😞

dharrigan21:10:11

so, clojure-lsp with deps is a non-starter?

snoe21:10:23

https://github.com/snoe/clojure-lsp/blob/master/src/clojure_lsp/crawler.clj#L209 It should be easy tho, just add a deps.edn project-file and the clj command to get classpath

snoe21:10:50

No, it's something that fell off my radar 😞

dharrigan21:10:21

Can it be brought back into your radar? 🙂 I think deps is increasing in popularity

dharrigan21:10:22

not sure (quite new) how to do your suggestion to get the classpath

dharrigan21:10:30

do I add that to my toy scratch.clj file?

snoe21:10:31

totally, if you want to try it locally try adding

{:project-path "deps.edn"
    :classpath-cmd ["clj" "-Spath"]}
to that vector

snoe21:10:02

(sorry it's been awhile since I was in this code)

snoe21:10:34

It looks like there's an option to put it in coc-settings.json "initializationOptions"

snoe21:10:06

but if you have the code checked out and are launching it from lein, the fastest test might be to modify that crawler.clj code

dharrigan21:10:50

Let me try 🙂

dharrigan21:10:10

will revisit tomorrow - chores to do! 🙂

dharrigan21:10:20

thanks for your help snoe! 🙂

snoe21:10:25

Sounds good, if not I'll try make time to fix it this weekend cause you're right deps.edn is getting way more popular

dharrigan05:10:01

That's great! Thank you. Very very much appreciated 😉

dharrigan06:10:21

Hi! Thanks for adding support for deps 🙂 I'll update the arch package.

walterl21:10:49

w00t! i didn't find that, thanks! i'll give it a try

sogaiu21:10:05

hope that works out 🙂