fixed lsp, orderless, corfu

irrelevant elements are now correctly filtered out of lsp by
orderless,corfu.

fixed some whitespace, indentation
This commit is contained in:
2026-08-12 00:12:21 +02:00
parent 811637003b
commit e82959cc66
9 changed files with 687 additions and 666 deletions
+114 -106
View File
@@ -1,130 +1,138 @@
;; Tree-sitter & LSP tweaks (Core transformative changes)
(use-package treesit-auto
:functions global-treesit-auto-mode
:config
(treesit-auto-add-to-auto-mode-alist 'all)
:hook (after-init . global-treesit-auto-mode)
:custom
(treesit-auto-install 'prompt)
)
:functions global-treesit-auto-mode
:config
(treesit-auto-add-to-auto-mode-alist 'all)
:hook (after-init . global-treesit-auto-mode)
:custom
(treesit-auto-install 'prompt)
)
(use-package treesit-fold
:defer t
:commands (treesit-fold-close
treesit-fold-close-all
treesit-fold-open
treesit-fold-toggle
treesit-fold-open-all
treesit-fold-mode
global-treesit-fold-mode
treesit-fold-open-recursively
treesit-fold-line-comment-mode)
:custom
(treesit-fold-line-count-show t)
(treesit-fold-line-count-format "--▼--")
:config
(set-face-attribute 'treesit-fold-replacement-face nil
:foreground "#808080"
:box nil
:weight 'bold))
:defer t
:commands (treesit-fold-close
treesit-fold-close-all
treesit-fold-open
treesit-fold-toggle
treesit-fold-open-all
treesit-fold-mode
global-treesit-fold-mode
treesit-fold-open-recursively
treesit-fold-line-comment-mode)
:custom
(treesit-fold-line-count-show t)
(treesit-fold-line-count-format "--▼--")
:config
(set-face-attribute 'treesit-fold-replacement-face nil
:foreground "#808080"
:box nil
:weight 'bold))
;; Tree-sitter hooks
(dolist (hook '(c-ts-mode-hook c++-ts-mode-hook java-ts-mode-hook rust-ts-mode-hook go-ts-mode-hook ruby-ts-mode-hook js-ts-mode-hook typescript-ts-mode-hook tsx-ts-mode-hook css-ts-mode-hook html-ts-mode-hook bash-ts-mode-hook cmake-ts-mode-hook dockerfile-ts-mode-hook json-ts-mode-hook toml-ts-mode-hook yaml-ts-mode-hook))
(add-hook hook #'treesit-fold-mode))
(add-hook hook #'treesit-fold-mode))
(with-eval-after-load 'treesit
(setq treesit-font-lock-level 4))
(setq treesit-font-lock-level 4))
(use-package mason
:defer t
:config
(mason-setup))
:defer t
:config
(mason-setup))
(defvar my/lsp-mode-hooks
'(c-mode-hook
c++-mode-hook
c-ts-mode-hook
c++-ts-mode-hook
typescript-ts-mode-hook
js-ts-mode-hook
tsx-ts-mode-hook
arduino-mode-hook
toml-ts-mode-hook
json-ts-mode-hook
python-mode-hook)
"List of major mode hooks to enable LSP.")
'(c-mode-hook
c++-mode-hook
c-ts-mode-hook
c++-ts-mode-hook
typescript-ts-mode-hook
js-ts-mode-hook
tsx-ts-mode-hook
arduino-mode-hook
toml-ts-mode-hook
json-ts-mode-hook
python-mode-hook)
"List of major mode hooks to enable LSP.")
(dolist (hook my/lsp-mode-hooks)
(add-hook hook #'lsp-deferred))
(add-hook hook #'lsp-deferred))
(use-package lsp-mode
:defer t
:commands lsp
:init
(setq lsp-keymap-prefix "C-l")
:config
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration))
(setq lsp-clients-clangd-executable "clangd"
lsp-clangd-binary-path "/usr/bin/clangd"
lsp-clients--clangd-default-executable "/usr/bind/clangd"
lsp-completion-provider :none
lsp-clients-clangd-args '("--header-insertion=iwyu" "--fallback-style=LLVM")
)
:defer t
:commands lsp
:init
(setq lsp-keymap-prefix "C-l")
:config
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration)
(setq lsp-clients-clangd-executable "clangd"
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-sort-initial-results t
lsp-clients-clangd-args '("--header-insertion=iwyu"
"--fallback-style=LLVM"
"-query-driver=/usr/bin/c++"
"--header-insertion-decorators")
(with-eval-after-load 'lsp-mode
(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 "r") #'lsp-rename)
;; Safe Capability Filter: Handles both association list (alist) and hash-table formats
(advice-add 'lsp--client-capabilities :filter-return
(lambda (caps)
(cond
;; If it's a hash table
((hash-table-p caps)
(when-let ((text-doc (gethash "textDocument" caps)))
(if (hash-table-p text-doc)
(remhash "inlineCompletion" text-doc)
(setcdr (assoc "inlineCompletion" text-doc) nil))))
;; If it's an association list (alist)
((listp caps)
(when-let ((text-doc (cdr (assoc 'textDocument caps))))
(setcdr (assoc 'textDocument caps)
(assq-delete-all 'inlineCompletion text-doc)))))
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
:defer t
:after lsp-mode
:commands lsp-ui-mode
:init
(setq lsp-ui-sideline-show-symbol t
lsp-ui-side-show-code-actions t
lsp-ui-sideline-show-hover t
lsp-ui-doc-enable t
lsp-ui-doc-delay 1
lsp-ui-doc-position 'at-point
lsp-ui-sideline-show-hover t
lsp-ui-sideline-show-diagnostics t
lsp-ui-side-show-code-actions t
lsp-ui-sideline-delay 0.25
)
)
lsp-enable-indentation t
lsp-enable-on-type-formatting nil
))
(with-eval-after-load 'lsp-mode
(add-to-list 'lsp-disabled-clients 'tailwindcss))
(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 "r") #'lsp-rename)
;; Safe Capability Filter: Handles both association list (alist) and hash-table formats
(advice-add 'lsp--client-capabilities :filter-return
(lambda (caps)
(cond
;; If it's a hash table
((hash-table-p caps)
(when-let ((text-doc (gethash "textDocument" caps)))
(if (hash-table-p text-doc)
(remhash "inlineCompletion" text-doc)
(setcdr (assoc "inlineCompletion" text-doc) nil))))
;; If it's an association list (alist)
((listp caps)
(when-let ((text-doc (cdr (assoc 'textDocument caps))))
(setcdr (assoc 'textDocument caps)
(assq-delete-all 'inlineCompletion text-doc)))))
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
:defer t
:after lsp-mode
:commands lsp-ui-mode
:init
(setq lsp-ui-sideline-show-symbol t
lsp-ui-side-show-code-actions t
lsp-ui-sideline-show-hover t
lsp-ui-doc-enable t
lsp-ui-doc-delay 1
lsp-ui-doc-position 'at-point
lsp-ui-sideline-show-hover t
lsp-ui-sideline-show-diagnostics t
lsp-ui-side-show-code-actions t
lsp-ui-sideline-delay 0.25
)
)
(with-eval-after-load 'lsp-mode
(add-to-list 'lsp-disabled-clients 'tailwindcss))
(provide 'dev-packages)