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

Try to use zeal docsets path for linux users and guess the docsets to activate for a buffer. #133

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 99 additions & 3 deletions helm-dash.el
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@
(defcustom helm-dash-docsets-path
(let ((original-dash-path (expand-file-name "~/Library/Application Support/Dash/DocSets")))
(if (and (string-equal system-type 'darwin)
(file-directory-p original-dash-path))
original-dash-path
(expand-file-name "~/.docsets")))
(file-directory-p original-dash-path))
original-dash-path
(let ((zeal-docsets-path (expand-file-name "~/.local/share/Zeal/Zeal/docsets")))
(if (file-directory-p zeal-docsets-path)
zeal-docsets-path
(expand-file-name "~/.docsets")))))
"Default path for docsets.
If you're setting this option manually, set it to an absolute
path. You can use `expand-file-name' function for that."
Expand Down Expand Up @@ -124,6 +127,99 @@ Suggested values are:
"Return the path where Dash's docsets are stored."
(expand-file-name helm-dash-docsets-path))


(defun helm-dash-check-mode-docsets-alist (&optional silentp)
(dolist (mode-docsets helm-dash-mode-docsets-alist)
(setf (cdr mode-docsets)
(let (ret)
(dolist (docset (cdr mode-docsets))
(if (helm-dash-docset-path docset)
(push docset ret)
(let ((docset-n (mapconcat #'identity (split-string docset) "_")))
(if (helm-dash-docset-path docset-n)
(push docset-n ret)
(unless silentp
(message "[helm-dash] Warning: Can not find %s docset!" docset))))))
ret))))

(let ((js-cd '("JavaScript" "jQuery" "Bootstrap_4" "React" "Lo-Dash" "BackboneJS" "RequireJS" "EmberJS"
"MongoDB" "NodeJS" "Meteor" "MooTools" "jQuery_UI" "jQuery_Mobile"))
(c-cd '("OpenGL_4" "OpenGL_3" "OpenGL_2"))
(css-cd '("CSS" "Bootstrap_4"))
(ja-cd '("Java_SE8" "Java_EE7" "JavaFX" "Akka"))
(erl-cd '("Erlang"))
(pl-cd '("Perl"))
(conf-cd '("Nginx" "Apache_HTTP_Server")))
(defcustom helm-dash-mode-docsets-alist
`((js-mode . ,js-cd) (js2-mode . ,js-cd)
(coffee-mode . ("CoffeeScript" ,@js-cd))
(typescript-mode . ("TypeScript" ,@js-cd))

,@(let (ret)
(dolist (cf-m '(conf-mode conf-javaprop-mode conf-ppd-mode conf-colon-mode conf-space-mode
conf-unix-mode conf-windows-mode conf-xdefaults-mode))
(push (cons cf-m conf-cd) ret))
ret)
(sh-mode . ("Bash" "Vagrant" "Ansible" "Chef"))
(tcl-mode . ("Tcl"))
(dockerfile-mode . ("Docker"))

(css-mode . ,css-cd)
(less-css-mode . ("Less" ,@css-cd))
(sass-mode . ("Sass" ,@css-cd))

(html-mode . ("HTML" ,@css-cd))
(haml-mode . ("Haml" "HTML" ,@css-cd))
(markdown-mode . ("Markdown" "HTML" ,@css-cd))
(jinja2-mode . ("Jinja" "HTML" ,@css-cd))
(latex-mode . ("LaTeX"))

(c-mode . ("C" "GLib" ,@c-cd "OpenCV_C"))
(c++-mode . ("C++" "Qt_5" "Boost" ,@c-cd "OpenCV_C++"))
(rust-mode . ("Rust"))

(cmake-mode . ("CMake"))

(java-mode . (,@ja-cd "Android" "OpenCV_Java" "Spring_Framework"))
(scala-mode . ("Scala" "Play_Scala" ,@ja-cd))
(clojure-mode . ("Clojure" ,@ja-cd))

(csharp-mode . ("Mono" "Unity_3D" "NET_Framework"))
(swift-mode . ("Swift"))
(go-mode . ("Go"))

(php-mode . ("PHP" "Laravel" "Yii" "Symfony"))
(ruby-mode . ("Ruby" "Ruby_on_Rails_5"))
(python-mode . ("Python_3" "Django" "SQLAlchemy" "Flask" "Jinja" "NumPy" "SciPy" "OpenCV_Python"))
(perl-mode . ,pl-cd)(cperl-mode . ,pl-cd)
(lua-mode . ("Lua_5.1"))

(sql-mode . ("PostgreSQL" "MySQL"))

(erlang-mode . ,erl-cd)
(elixir-mode . ("Elixir" ,@erl-cd))

(emacs-lisp-mode . ("Emacs_Lisp"))
(lisp-mode . ("Common_Lisp"))
(racket-mode . ("Racket"))
(ess-mode . ("R"))

(haskell-mode . ("Haskell"))
(ocaml-mode . ("OCaml")))
"What docsets to activate for a major-mode."
:group 'helm-dash
:type '(alist :key-type (symbol :tag "Mode") :value-type (repeat :tag "Docsets" string))
:set #'(lambda (sym val)
(set-default sym val)
(helm-dash-check-mode-docsets-alist))))

;;;###autoload
(defun helm-dash-set-apropriate-major-mode-docsets ()
(let ((docsets (cdr (assoc major-mode helm-dash-mode-docsets-alist))))
(when docsets
(setq-local helm-dash-docsets docsets))))


(defun helm-dash-sql (db-path sql)
"Run the sql command, parse the results and display errors"
(helm-dash-parse-sql-results
Expand Down