fixed arduino again I think
using arduino-lsp instead of clangd let gemini rewrite the whole lsp use-package def
This commit is contained in:
@@ -252,9 +252,6 @@
|
|||||||
(use-package markdown-mode
|
(use-package markdown-mode
|
||||||
:mode "\\.qd$")
|
:mode "\\.qd$")
|
||||||
|
|
||||||
(use-package c++-mode
|
|
||||||
:mode "\\.ino$")
|
|
||||||
|
|
||||||
(use-package typescript-ts-mode
|
(use-package typescript-ts-mode
|
||||||
:mode "\\.ts$")
|
:mode "\\.ts$")
|
||||||
|
|
||||||
|
|||||||
+42
-38
@@ -33,75 +33,79 @@
|
|||||||
:config
|
:config
|
||||||
(mason-setup))
|
(mason-setup))
|
||||||
|
|
||||||
|
(use-package lsp-mode
|
||||||
(defvar my/lsp-mode-hooks
|
:defer t
|
||||||
;List of major mode hooks to enable LSP.
|
:commands (lsp lsp-deferred)
|
||||||
'(c-ts-mode-hook
|
:init
|
||||||
|
(setq lsp-keymap-prefix "C-l")
|
||||||
|
:hook
|
||||||
|
((c-mode-hook
|
||||||
|
c++-mode-hook
|
||||||
|
c-ts-mode-hook
|
||||||
c++-ts-mode-hook
|
c++-ts-mode-hook
|
||||||
|
arduino-mode-hook
|
||||||
typescript-ts-mode-hook
|
typescript-ts-mode-hook
|
||||||
js-ts-mode-hook
|
js-ts-mode-hook
|
||||||
tsx-ts-mode-hook
|
tsx-ts-mode-hook
|
||||||
arduino-mode-hook
|
|
||||||
toml-ts-mode-hook
|
toml-ts-mode-hook
|
||||||
json-ts-mode-hook
|
json-ts-mode-hook
|
||||||
python-ts-mode-hook)
|
python-ts-mode-hook) . lsp-deferred)
|
||||||
)
|
|
||||||
|
|
||||||
(dolist (hook my/lsp-mode-hooks)
|
|
||||||
(add-hook hook #'lsp-deferred))
|
|
||||||
|
|
||||||
(use-package lsp-mode
|
|
||||||
:defer t
|
|
||||||
:commands lsp
|
|
||||||
:init
|
|
||||||
(setq lsp-keymap-prefix "C-l")
|
|
||||||
:config
|
:config
|
||||||
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration)
|
;; --- General LSP Settings ---
|
||||||
(setq lsp-clients-clangd-executable "clangd"
|
(setq lsp-completion-provider :none
|
||||||
lsp-clangd-binary-path "/usr/bin/clangd"
|
|
||||||
lsp-clients--clangd-default-executable "/usr/bin/clangd"
|
|
||||||
lsp-completion-provider :none
|
|
||||||
lsp-completion-enable-filtering nil
|
lsp-completion-enable-filtering nil
|
||||||
lsp-completion-sort-initial-results t
|
lsp-completion-sort-initial-results t
|
||||||
|
lsp-enable-indentation t
|
||||||
|
lsp-enable-on-type-formatting nil)
|
||||||
|
|
||||||
|
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration)
|
||||||
|
|
||||||
|
;; --- C / C++ Configuration (clangd) ---
|
||||||
|
(setq lsp-clients-clangd-executable "/usr/bin/clangd"
|
||||||
|
lsp-clients--clangd-default-executable "/usr/bin/clangd"
|
||||||
lsp-clients-clangd-args '("--header-insertion=iwyu"
|
lsp-clients-clangd-args '("--header-insertion=iwyu"
|
||||||
"--fallback-style=LLVM"
|
"--fallback-style=LLVM"
|
||||||
"-query-driver=/usr/bin/c++"
|
"--query-driver=/usr/bin/c++,/usr/bin/g++,/home/*/.arduino15/packages/**/bin/*"
|
||||||
"--header-insertion-decorators")
|
"--header-insertion-decorators"))
|
||||||
|
|
||||||
lsp-enable-indentation t
|
;; Map major modes to LSP language IDs
|
||||||
lsp-enable-on-type-formatting nil
|
(add-to-list 'lsp-language-id-configuration '(c-ts-mode . "c"))
|
||||||
|
(add-to-list 'lsp-language-id-configuration '(c++-ts-mode . "cpp"))
|
||||||
|
(add-to-list 'lsp-language-id-configuration '(arduino-mode . "arduino"))
|
||||||
|
|
||||||
|
;; --- Arduino Language Server Registration ---
|
||||||
|
(lsp-register-client
|
||||||
|
(make-lsp-client
|
||||||
|
:new-connection (lsp-stdio-connection
|
||||||
|
(list "arduino-language-server"
|
||||||
|
"-clangd" "/usr/bin/clangd"
|
||||||
|
"-cli" "/usr/bin/arduino-cli"
|
||||||
|
"-cli-config" (expand-file-name "~/.arduino15/arduino-cli.yaml")
|
||||||
))
|
))
|
||||||
|
:activation-fn (lsp-activate-on "arduino")
|
||||||
|
:major-modes '(arduino-mode)
|
||||||
|
:server-id 'arduino-ls))
|
||||||
|
|
||||||
(with-eval-after-load 'lsp-mode
|
;; --- Keybindings ---
|
||||||
(define-key lsp-command-map (kbd "a") #'lsp-execute-code-action)
|
(define-key lsp-command-map (kbd "a") #'lsp-execute-code-action)
|
||||||
(define-key lsp-command-map (kbd "d") #'lsp-ui-doc-glance)
|
(define-key lsp-command-map (kbd "d") #'lsp-ui-doc-glance)
|
||||||
(define-key lsp-command-map (kbd "r") #'lsp-rename)
|
(define-key lsp-command-map (kbd "r") #'lsp-rename)
|
||||||
|
|
||||||
;; Safe Capability Filter: Handles both association list (alist) and hash-table formats
|
;; Filter out unsupported inlineCompletion capability
|
||||||
(advice-add 'lsp--client-capabilities :filter-return
|
(advice-add 'lsp--client-capabilities :filter-return
|
||||||
(lambda (caps)
|
(lambda (caps)
|
||||||
(cond
|
(cond
|
||||||
;; If it's a hash table
|
|
||||||
((hash-table-p caps)
|
((hash-table-p caps)
|
||||||
(when-let ((text-doc (gethash "textDocument" caps)))
|
(when-let ((text-doc (gethash "textDocument" caps)))
|
||||||
(if (hash-table-p text-doc)
|
(if (hash-table-p text-doc)
|
||||||
(remhash "inlineCompletion" text-doc)
|
(remhash "inlineCompletion" text-doc)
|
||||||
(setcdr (assoc "inlineCompletion" text-doc) nil))))
|
(setcdr (assoc "inlineCompletion" text-doc) nil))))
|
||||||
;; If it's an association list (alist)
|
|
||||||
((listp caps)
|
((listp caps)
|
||||||
(when-let ((text-doc (cdr (assoc 'textDocument caps))))
|
(when-let ((text-doc (cdr (assoc 'textDocument caps))))
|
||||||
(setcdr (assoc 'textDocument caps)
|
(setcdr (assoc 'textDocument caps)
|
||||||
(assq-delete-all 'inlineCompletion text-doc)))))
|
(assq-delete-all 'inlineCompletion text-doc)))))
|
||||||
caps))
|
caps)))
|
||||||
|
|
||||||
;; Set up arduino-mode safely after lsp-mode is loaded
|
|
||||||
(add-to-list 'lsp-language-id-configuration '(arduino-mode . "cpp"))
|
|
||||||
(lsp-register-client
|
|
||||||
(make-lsp-client
|
|
||||||
:new-connection (lsp-stdio-connection '("clangd" "--header-insertion=never"))
|
|
||||||
:activation-fn (lsp-activate-on "arduino")
|
|
||||||
:server-id 'lsp-arduino-clangd
|
|
||||||
)))
|
|
||||||
|
|
||||||
(use-package lsp-ui
|
(use-package lsp-ui
|
||||||
:defer t
|
:defer t
|
||||||
|
|||||||
Reference in New Issue
Block a user