2018-03-18 15:31:32 -04:00
|
|
|
;;; lang/lua/config.el -*- lexical-binding: t; -*-
|
2015-06-15 09:06:10 +02:00
|
|
|
|
2018-06-25 15:54:38 +02:00
|
|
|
;; sp's default rules are obnoxious, so disable them
|
|
|
|
(provide 'smartparens-lua)
|
|
|
|
|
2018-09-07 19:36:16 -04:00
|
|
|
|
2019-01-25 03:10:28 -05:00
|
|
|
;;
|
2020-11-09 21:24:24 -05:00
|
|
|
;;; Major modes
|
2019-01-25 03:10:28 -05:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! lua-mode
|
2019-02-16 19:03:36 -05:00
|
|
|
:defer t
|
2019-01-25 03:10:28 -05:00
|
|
|
:init
|
|
|
|
;; lua-indent-level defaults to 3 otherwise. Madness.
|
2019-08-23 01:04:41 -04:00
|
|
|
(setq lua-indent-level 2)
|
2019-01-25 03:10:28 -05:00
|
|
|
:config
|
2018-06-15 17:27:48 +02:00
|
|
|
(set-lookup-handlers! 'lua-mode :documentation 'lua-search-documentation)
|
2018-06-15 12:30:56 +02:00
|
|
|
(set-electric! 'lua-mode :words '("else" "end"))
|
2019-02-18 01:56:38 -05:00
|
|
|
(set-repl-handler! 'lua-mode #'+lua/open-repl)
|
2020-06-04 20:02:46 -04:00
|
|
|
(set-company-backend! 'lua-mode '(company-lua company-yasnippet))
|
|
|
|
|
2022-08-12 20:29:19 +02:00
|
|
|
(when (modulep! +lsp)
|
2022-03-24 02:19:52 +01:00
|
|
|
(add-hook 'lua-mode-local-vars-hook #'lsp! 'append)
|
2021-01-03 17:07:22 -05:00
|
|
|
|
2022-08-12 20:29:19 +02:00
|
|
|
(when (modulep! :tools lsp +eglot)
|
2022-08-14 18:10:01 +02:00
|
|
|
(defvar +lua-lsp-dir (concat doom-data-dir "lsp/lua-language-server/")
|
2021-01-03 17:07:22 -05:00
|
|
|
"Absolute path to the directory of sumneko's lua-language-server.
|
|
|
|
|
|
|
|
This directory MUST contain the 'main.lua' file and be the in-source build of
|
|
|
|
lua-language-server.")
|
|
|
|
|
|
|
|
(defun +lua-generate-lsp-server-command ()
|
|
|
|
;; The absolute path to lua-language-server binary is necessary because
|
|
|
|
;; the bundled dependencies aren't found otherwise. The only reason this
|
|
|
|
;; is a function is to dynamically change when/if `+lua-lsp-dir' does
|
|
|
|
(list (or (executable-find "lua-language-server")
|
|
|
|
(doom-path +lua-lsp-dir
|
2022-08-18 17:06:42 +02:00
|
|
|
(cond (IS-MAC "bin/macOS")
|
|
|
|
(IS-LINUX "bin/Linux")
|
|
|
|
(IS-WINDOWS "bin/Windows"))
|
2021-01-03 17:07:22 -05:00
|
|
|
"lua-language-server"))
|
|
|
|
"-E" "-e" "LANG=en"
|
|
|
|
(doom-path +lua-lsp-dir "main.lua")))
|
|
|
|
|
|
|
|
(set-eglot-client! 'lua-mode (+lua-generate-lsp-server-command)))))
|
2015-06-15 09:06:10 +02:00
|
|
|
|
2016-05-01 17:23:37 -04:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! moonscript
|
2022-08-12 20:29:19 +02:00
|
|
|
:when (modulep! +moonscript)
|
2019-07-09 01:01:44 +02:00
|
|
|
:defer t
|
|
|
|
:config
|
|
|
|
(setq-hook! 'moonscript-mode-hook
|
|
|
|
moonscript-indent-offset tab-width)
|
|
|
|
(add-hook! 'moonscript-mode-hook
|
2019-09-06 00:34:23 -04:00
|
|
|
#'+lua-moonscript-fix-single-quotes-h
|
|
|
|
#'+lua-moonscript-fontify-interpolation-h)
|
2022-08-12 20:29:19 +02:00
|
|
|
(when (modulep! :checkers syntax)
|
2019-09-06 00:33:07 -04:00
|
|
|
(require 'flycheck-moonscript nil t)))
|
2016-05-01 17:23:37 -04:00
|
|
|
|
2017-02-19 18:57:16 -05:00
|
|
|
|
2020-11-09 21:24:24 -05:00
|
|
|
(use-package! fennel-mode
|
2022-08-12 20:29:19 +02:00
|
|
|
:when (modulep! +fennel)
|
2020-11-09 21:24:24 -05:00
|
|
|
:defer t
|
|
|
|
:config
|
2021-07-28 15:26:43 -04:00
|
|
|
(set-lookup-handlers! 'fennel-mode
|
|
|
|
:definition #'fennel-find-definition
|
|
|
|
:documentation #'fennel-show-documentation)
|
|
|
|
(set-repl-handler! 'fennel-mode #'fennel-repl)
|
|
|
|
|
|
|
|
(setq-hook! 'fennel-mode-hook
|
|
|
|
;; To match the `tab-width' default for other lisp modes
|
|
|
|
tab-width 2
|
|
|
|
;; Don't treat autoloads or sexp openers as outline headers, we have
|
|
|
|
;; hideshow for that.
|
|
|
|
outline-regexp "[ \t]*;;;;* [^ \t\n]"))
|
2020-11-09 21:24:24 -05:00
|
|
|
|
|
|
|
|
2017-02-19 18:57:16 -05:00
|
|
|
;;
|
2019-04-06 00:35:43 -04:00
|
|
|
;;; Frameworks
|
2017-02-19 18:57:16 -05:00
|
|
|
|
2017-03-02 18:20:46 -05:00
|
|
|
(def-project-mode! +lua-love-mode
|
2019-07-21 14:49:09 +02:00
|
|
|
:modes '(moonscript-mode lua-mode markdown-mode json-mode)
|
2022-11-22 19:25:44 +01:00
|
|
|
:when (+lua-love-project-root)
|
2018-09-04 03:04:00 +02:00
|
|
|
:on-load
|
2019-06-27 20:26:29 +03:00
|
|
|
(progn
|
|
|
|
(set-project-type! 'love2d
|
|
|
|
:predicate #'+lua-love-project-root
|
2019-07-09 01:01:44 +02:00
|
|
|
:run #'+lua-love-build-command)
|
2019-06-27 20:26:29 +03:00
|
|
|
(map! :localleader
|
|
|
|
:map +lua-love-mode-map
|
|
|
|
"b" #'+lua/run-love-game)))
|