Fix root finding.
The problem was projectile
This commit is contained in:
parent
6f70238b4e
commit
3b2f0a4cb4
70
.emacs
70
.emacs
@ -185,15 +185,15 @@
|
|||||||
(evil-mode 1)
|
(evil-mode 1)
|
||||||
|
|
||||||
;; Force modes to start in Emacs state
|
;; Force modes to start in Emacs state
|
||||||
(dolist (mode '(;;Buffer-menu-mode
|
;;(dolist (mode '(;;Buffer-menu-mode
|
||||||
;;ibuffer-mode
|
;;;;ibuffer-mode
|
||||||
dired-mode
|
;;dired-mode
|
||||||
help-mode
|
;;help-mode
|
||||||
bookmark-bmenu-mode
|
;;bookmark-bmenu-mode
|
||||||
gnus-summary-mode
|
;;gnus-summary-mode
|
||||||
gnus-group-mode
|
;;gnus-group-mode
|
||||||
package-menu-mode))
|
;;package-menu-mode))
|
||||||
(evil-set-initial-state mode 'emacs))
|
;;(evil-set-initial-state mode 'emacs))
|
||||||
|
|
||||||
;; Correct keybindings for minibuffer maps using actual keymap objects
|
;; Correct keybindings for minibuffer maps using actual keymap objects
|
||||||
(dolist (keymap '(minibuffer-local-map
|
(dolist (keymap '(minibuffer-local-map
|
||||||
@ -247,12 +247,14 @@
|
|||||||
(setq company-minimum-prefix-length 1
|
(setq company-minimum-prefix-length 1
|
||||||
company-idle-delay 0.0)) ;; Show completions immediately
|
company-idle-delay 0.0)) ;; Show completions immediately
|
||||||
|
|
||||||
;; Install and configure Projectile
|
|
||||||
(use-package projectile
|
(use-package projectile
|
||||||
:init
|
:init
|
||||||
(projectile-mode +1)
|
(projectile-mode)
|
||||||
:bind (:map projectile-mode-map
|
:config
|
||||||
("s-p" . projectile-command-map)))
|
(setq projectile-project-root-files '(".git" ".lsp-root"))
|
||||||
|
;;(setq projectile-project-root-files-bottom-up '(".git" ".clangd"))
|
||||||
|
(projectile-mode +1))
|
||||||
|
|
||||||
;; Install and bind Magit
|
;; Install and bind Magit
|
||||||
(use-package magit
|
(use-package magit
|
||||||
@ -278,9 +280,35 @@
|
|||||||
(rust-mode . lsp))
|
(rust-mode . lsp))
|
||||||
:commands lsp
|
:commands lsp
|
||||||
:config
|
:config
|
||||||
(setq lsp-prefer-flymake nil) ;; Use lsp-ui and flycheck instead of flymake
|
(setq lsp-prefer-flymake nil)
|
||||||
(setq lsp-enable-snippet t) ;; Disable snippet support if not needed
|
(setq lsp-enable-snippet t)
|
||||||
(setq lsp-headerline-breadcrumb-enable nil)) ;; Disable breadcrumb for performance
|
(setq lsp-headerline-breadcrumb-enable nil)
|
||||||
|
|
||||||
|
;; Enhanced project root detection with debug logging
|
||||||
|
(defun my/lsp-get-project-root ()
|
||||||
|
"Find the project root by locating the nearest .git directory with validation."
|
||||||
|
(let* ((current-file (or (buffer-file-name) default-directory))
|
||||||
|
(root-dir (locate-dominating-file current-file ".git"))
|
||||||
|
(valid-root (when root-dir
|
||||||
|
(expand-file-name root-dir))))
|
||||||
|
(when valid-root
|
||||||
|
(message "[LSP] Detected project root: %s" valid-root)
|
||||||
|
valid-root)))
|
||||||
|
|
||||||
|
;; Set project root detection for C/C++ before LSP initializes
|
||||||
|
(add-hook 'c-mode-hook (lambda ()
|
||||||
|
(setq-local lsp-project-root-function #'my/lsp-get-project-root)
|
||||||
|
(message "[LSP] C mode root: %s" (my/lsp-get-project-root))))
|
||||||
|
|
||||||
|
(add-hook 'c++-mode-hook (lambda ()
|
||||||
|
(setq-local lsp-project-root-function #'my/lsp-get-project-root)
|
||||||
|
(message "[LSP] C++ mode root: %s" (my/lsp-get-project-root))))
|
||||||
|
|
||||||
|
;; Configure ignored directories for better performance
|
||||||
|
(setq lsp-file-watch-ignored '("[/\\\\]\\.git$"
|
||||||
|
"[/\\\\]build$"
|
||||||
|
"[/\\\\]bin$"
|
||||||
|
"[/\\\\]tests$")))
|
||||||
|
|
||||||
(use-package lsp-ui
|
(use-package lsp-ui
|
||||||
:commands lsp-ui-mode
|
:commands lsp-ui-mode
|
||||||
@ -335,6 +363,16 @@
|
|||||||
(setq rust-format-on-save t)
|
(setq rust-format-on-save t)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
;; ===========================
|
||||||
|
;; C/C++ Line Length Configuration
|
||||||
|
;; ===========================
|
||||||
|
(defun my/c-mode-line-limit ()
|
||||||
|
"Set 80-character line limit for C/C++ files."
|
||||||
|
(setq fill-column 80)
|
||||||
|
(display-fill-column-indicator-mode 1)
|
||||||
|
)
|
||||||
|
(add-hook 'c-mode-hook #'my/c-mode-line-limit)
|
||||||
|
|
||||||
(message "Emacs init loaded.")
|
(message "Emacs init loaded.")
|
||||||
(custom-set-variables
|
(custom-set-variables
|
||||||
;; custom-set-variables was added by Custom.
|
;; custom-set-variables was added by Custom.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user