Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

universal-ctags #135

Open
rofrol opened this issue Jun 29, 2018 · 1 comment
Open

universal-ctags #135

rofrol opened this issue Jun 29, 2018 · 1 comment

Comments

@rofrol
Copy link

rofrol commented Jun 29, 2018

Looks like universal-ctags shows support for Elm:

$ ctags --list-languages | grep -i elm
Elm

There is also this file https://github.com/kbsymanz/ctags-elm

Which can be used like that for universal ctags:

$ mkdir ~/.ctags.d
$ cd ~/.ctags.d
$ curl -s https://raw.githubusercontent.com/kbsymanz/ctags-elm/master/.ctags -o elm.ctags

But then it shows this:

$ ctags --list-languages | grep -i elm
ctags: Warning: Language "Elm" already defined
ctags: Warning: Don't reuse the kind letter `c' in a language Elm (old: "constructor", new: "constant")
ctags: Warning: Don't reuse the kind letter `a' in a language Elm (old: "alias", new: "type-alias")
ctags: Warning: Don't reuse the kind letter `t' in a language Elm (old: "type", new: "type-cons")
ctags: Warning: Don't reuse the kind letter `t' in a language Elm (old: "type", new: "type-cons")
Elm

Windows

There is some problem with elm-mode on Windows. It just doesn't generate TAGS file.

Now I'm using this command in git bash:

$ rg --files -telm | ctags -e -L -

I'm using ctags from here https://github.com/universal-ctags/ctags-win32/releases

My config:

(use-package elm-mode
    :mode ("\\.elm\\'" . elm-mode)
    :straight t
    :init
    (progn
	(defconst elm-package-json
	  "elm-package.json"
	  "The name of the package JSON configuration file.")
 
	(defun rofrol/elm--find-dependency-file-path ()
	  "Recursively search for a directory containing a package JSON file."
	  (or (locate-dominating-file default-directory elm-package-json)
	      (file-name-as-directory (f-dirname (buffer-file-name)))))

	(defun rofrol/elm--has-dependency-file ()
	  "Check if a dependency file exists."
	  (f-exists? (f-join (rofrol/elm--find-dependency-file-path) elm-package-json)))
 
	(defun rofrol/elm-mode-generate-tags ()
	  "Generate a TAGS file for the current project."
	  (interactive)
	  (when (and (rofrol/elm--has-dependency-file) (eq major-mode 'elm-mode))
	    (let* ((default-directory (rofrol/elm--find-dependency-file-path))
	          (ctags-command "rg --files -telm | ctags -e -L -"))
	          (call-process-shell-command (concat ctags-command "&") nil 0))))
	
	(add-hook 'after-save-hook 'rofrol/elm-mode-generate-tags nil 'make-it-local)
	
	(defun init-elm-mode ()
          "Disable electric-indent-mode and let indentation cycling feature work"
          (if (fboundp 'electric-indent-local-mode)
              (electric-indent-local-mode -1))
          (add-to-list 'company-backends 'company-elm)
          (setq elm-format-on-save t))

        (setq tags-revert-without-query 1)
        ;; (setq elm-tags-on-save t))

	(add-hook 'elm-mode-hook 'init-elm-mode)))
@purcell
Copy link
Collaborator

purcell commented Feb 22, 2021

It's not clear to me if there's an action being proposed here, or an elm-mode issue being reported. Is this still on your radar, @rofrol?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants