3 Commits

Author SHA1 Message Date
  Juan Placencia 6c426860c2 Formatting 3 years ago
  Juan Placencia 4181f2937b Refine git settings 3 years ago
  Juan Placencia b995505100 Improve LSP settings 3 years ago
6 changed files with 107 additions and 77 deletions
Split View
  1. +5
    -5
      init.el
  2. +18
    -0
      uno/modules/dev/git.org
  3. +2
    -0
      uno/modules/dev/lsp.org
  4. +75
    -0
      uno/modules/lang/js/lsp.org
  5. +7
    -7
      uno/modules/lang/js/ts.org
  6. +0
    -65
      uno/modules/lang/js/yarn.org

+ 5
- 5
init.el View File

@ -1,15 +1,15 @@
;; Set up straight.el
(setq
straight-profiles `((nil . ,(expand-file-name "straight.lock.el" user-emacs-directory)))
straight-use-package-by-default t)
straight-profiles `((nil . ,(expand-file-name "straight.lock.el" user-emacs-directory)))
straight-use-package-by-default t)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))

+ 18
- 0
uno/modules/dev/git.org View File

@ -17,6 +17,8 @@ Define Git dev package.
#+BEGIN_SRC emacs-lisp
(use-package magit
:after uno-dev-git
:custom
(magit-diff-refine-hunk t)
:general
(uno-leader-define
"g" '(:ignore t :which-key "Git")
@ -84,3 +86,19 @@ Define Git dev package.
:config
(uno/add-prog-mode 'gitattributes-mode))
#+END_SRC
* Diff Highlight
#+BEGIN_SRC emacs-lisp
(use-package diff-hl
:after uno-dev-git
:hook
(uno-prog-mode . turn-on-diff-hl-mode)
(uno-prog-mode . diff-hl-flydiff-mode))
(use-package diff-hl
:after (uno-dev-git magit)
:hook
(magit-pre-refresh . diff-hl-magit-pre-refresh)
(magit-post-refresh . diff-hl-magit-post-refresh))
#+END_SRC

+ 2
- 0
uno/modules/dev/lsp.org View File

@ -28,9 +28,11 @@ Define LSP dev package.
"a" '(lsp-execute-code-action :which-key "Execute action")
"h" '(:ignore t :which-key "Help")
"hh" '(lsp-describe-thing-at-point :which-key "Describe")
"R" '(lsp-workspace-restart :which-key "Restart")
"r" '(:ignore t :which-key "Refactor")
"rr" '(lsp-rename :which-key "Rename"))
:config
(uno/add-useless-buffer "\\*lsp-install")
(uno/add-useless-buffer "\\*lsp-log\\*")
(uno/handle-side-window "\\*lsp-help\\*"))

+ 75
- 0
uno/modules/lang/js/lsp.org View File

@ -0,0 +1,75 @@
#+TITLE: Language - JavaScript - LSP
#+AUTHOR: Juan Placencia
* Package
Define JavaScript language LSP Integration package.
#+BEGIN_SRC emacs-lisp
(use-package emacs
:after (uno-lang-js uno-dev-lsp projectile)
:config
(provide 'uno-lang-js-lsp))
#+END_SRC
* LSP Integration
#+BEGIN_SRC emacs-lisp
(use-package emacs
:after uno-lang-js-lsp
:init
(require 'seq)
(defun uno/lang/js/lsp/add-to-local (name file)
"Add NAME dependency from FILE to local instance."
(when (uno/lang/js/lsp/local-provider file)
(lsp-dependency name `(:local ,file))
t))
(defun uno/lang/js/lsp/check ()
"Set up support with local SDK instance."
(when (uno/lang/js/lsp/local-provider)
(require 'lsp-javascript)
(make-local-variable 'lsp-enabled-clients)
(plist-put lsp-deps-providers
:local '(:path uno/lang/js/lsp/local-provider))
(setq-local lsp-auto-guess-root t)
(run-hooks 'uno-lang-js-lsp-hook)))
(defun uno/lang/js/lsp/local-provider (&optional path)
"Provide path for local SDK instance relative to PATH."
(seq-reduce
(lambda (current sdk)
(if current
current
(let ((-path (concat (projectile-project-root) sdk path)))
(if (file-exists-p -path) -path nil))))
'(".yarn/sdks/" "node_modules/")
nil))
(defun uno/lang/js/lsp/local-provider-type (&optional path)
"Check SDK instance type relative to PATH."
(let ((-path (uno/lang/js/lsp/local-provider path)))
(cond
(string-match-p ".yarn/sdks/" -path) "yarn")
(string-match-p "node_modules/" -path) "npm")))
#+END_SRC
** ESLint Integration
#+BEGIN_SRC emacs-lisp
(use-package emacs
:after (uno-lang-js-lsp flycheck)
:hook
(uno-lang-js-lsp . uno/lang/js/eslint/add)
:init
(defun uno/lang/js/eslint/add ()
"Add support for ESLint."
(when (uno/lang/js/lsp/local-provider "eslint/bin/eslint.js")
(let ((-eslint-full
(uno/lang/js/lsp/local-provider "eslint/bin/eslint.js"))
(-node-path (uno/lang/js/lsp/local-provider)))
(setq-local
flycheck-javascript-eslint-executable -eslint-full
lsp-eslint-node-path -node-path
lsp-eslint-package-manager (uno/lang/js/lsp/local-provider-type)))
(push 'eslint lsp-enabled-clients)))
(uno/add-useless-buffer "\\*eslint\\*")
(uno/add-useless-buffer "\\*eslint::.*\\*"))
#+END_SRC

+ 7
- 7
uno/modules/lang/js/ts.org View File

@ -35,18 +35,18 @@ Define TypeScript JavaScript language package.
#+BEGIN_SRC emacs-lisp
(use-package emacs
:after (uno-lang-js-ts uno-lang-js-yarn typescript-mode)
:after (uno-lang-js-ts uno-lang-js-lsp typescript-mode)
:hook
(uno-lang-js-yarn . uno/lang/js/ts/yarn)
((typescript-mode typescript-tsx-mode) . uno/lang/js/yarn/check)
(uno-lang-js-lsp . uno/lang/js/ts/lsp)
((typescript-mode typescript-tsx-mode) . uno/lang/js/lsp/check)
:init
(defun uno/lang/js/ts/yarn ()
"Attempt to load SDKs with Yarn support."
(defun uno/lang/js/ts/lsp ()
"Attempt to load local SDKs."
(when (and (member major-mode '(typescript-mode typescript-tsx-mode))
(uno/lang/js/yarn/add-to-local-lsp
(uno/lang/js/lsp/add-to-local
'typescript-language-server
"typescript-language-server/lib/cli.js")
(uno/lang/js/yarn/add-to-local-lsp
(uno/lang/js/lsp/add-to-local
'typescript
"typescript/bin/tsserver"))
(push 'ts-ls lsp-enabled-clients)

+ 0
- 65
uno/modules/lang/js/yarn.org View File

@ -1,65 +0,0 @@
#+TITLE: Language - JavaScript - Yarn
#+AUTHOR: Juan Placencia
* Package
Define JavaScript language package.
#+BEGIN_SRC emacs-lisp
(use-package emacs
:after (uno-lang-js uno-dev-lsp projectile)
:config
(provide 'uno-lang-js-yarn))
#+END_SRC
* LSP Integration
#+BEGIN_SRC emacs-lisp
(use-package emacs
:after uno-lang-js-yarn
:init
(defun uno/lang/js/yarn/add-to-local-lsp (name file)
"Add NAME dependency from FILE to local yarn instance."
(when (uno/lang/js/yarn/local-p file)
(lsp-dependency name `(:yarn-local ,file))
t))
(defun uno/lang/js/yarn/check ()
"Set up support with local Yarn instance."
(when (uno/lang/js/yarn/local-p)
(require 'lsp-javascript)
(make-local-variable 'lsp-enabled-clients)
(plist-put lsp-deps-providers
:yarn-local '(:path uno/lang/js/yarn/local-provider))
(setq-local lsp-auto-guess-root t)
(run-hooks 'uno-lang-js-yarn-hook)))
(defun uno/lang/js/yarn/local-p (&optional file)
"Check if Yarn SDK is available locally."
(if file
(file-exists-p (uno/lang/js/yarn/local-provider file))
(file-directory-p (uno/lang/js/yarn/local-provider))))
(defun uno/lang/js/yarn/local-provider (&optional path)
"Provide path for local yarn instance relative to PATH."
(concat (projectile-project-root) ".yarn/sdks/" path)))
#+END_SRC
** ESLint Integration
#+BEGIN_SRC emacs-lisp
(use-package emacs
:after (uno-lang-js-yarn flycheck)
:hook
(uno-lang-js-yarn . uno/lang/js/eslint/add)
:init
(defun uno/lang/js/eslint/add ()
"Add support for ESLint."
(when (uno/lang/js/yarn/local-p "eslint/bin/eslint.js")
(let ((-eslint-full (uno/lang/js/yarn/local-provider "eslint/bin/eslint.js"))
(-node-path (uno/lang/js/yarn/local-provider)))
(setq-local
flycheck-javascript-eslint-executable -eslint-full
lsp-eslint-node-path -node-path
lsp-eslint-package-manager "yarn"))
(push 'eslint lsp-enabled-clients)))
(uno/add-useless-buffer "\\*eslint\\*")
(uno/add-useless-buffer "\\*eslint::.*\\*"))
#+END_SRC

Loading…
Cancel
Save