Making DOOM EMACs a powerful IDE
LSP in Treesitter
To make DOOM act like a modern IDE, you will need both integrated. LSP (Language Server Protocol) use JSON-RPC with a language server instance and pass useful information, such as autocompletion, syntax errors, etc, to the buffer. To enable this, add the "+lsp" flag to your given language. For the completion framework, I reccomed enabling "company" instead of corfu as it is more feature rich with things such as lsp ui doc tooltips
Make sure to run doom sync;doom doctor and ensure your language server is installed.
Treesitter is necessary for full syntax highlighting and anaylsis. It creates a full AST of your code. An LSP might have some code grammar implemented. To enable it is a bit more tricky...
First, enable +treesitter, then add the following code for all the treesitter sources. You might need to go on github and find the treesitter grammar package for your language if it is not below:
Formatted [Language name, url, branch name, source folder]
(setq treesit-language-source-alist
'((bash "https://github.com/tree-sitter/tree-sitter-bash")
(cmake "https://github.com/uyha/tree-sitter-cmake")
(css "https://github.com/tree-sitter/tree-sitter-css")
(elisp "https://github.com/Wilfred/tree-sitter-elisp")
(go "https://github.com/tree-sitter/tree-sitter-go")
(html "https://github.com/tree-sitter/tree-sitter-html")
(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "master" "src")
(json "https://github.com/tree-sitter/tree-sitter-json")
(make "https://github.com/alemuller/tree-sitter-make")
(markdown "https://github.com/ikatyang/tree-sitter-markdown")
(python "https://github.com/tree-sitter/tree-sitter-python")
(toml "https://github.com/tree-sitter/tree-sitter-toml")
(tsx "https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src")
(typescript "https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src")
(yaml "https://github.com/ikatyang/tree-sitter-yaml")
(rust "https://github.com/tree-sitter/tree-sitter-rust" "master" "src")))
Then run 'M-x treesit-install-language-server' and select your language
DAP
For DAP (Debug Adapter Protocol) you will have to enable the 'debugger +lsp' flag in your init.el. I reccomed turning off the controls gui as I found it to be broken, and only use hotkeys to debug.
;;; configs/dap.el -*- lexical-binding: t; -*-
;; Require dap-ui early and enable it once
(require 'dap-ui)
(dap-ui-mode 1)
;; Enable dap auto-configure features for full UI integration
(setq dap-auto-configure-features '(sessions locals tooltip))
(dap-auto-configure-mode +1)
;; Enable dap debug logging (optional, useful for troubleshooting)
(setq dap-print-io t)
;; Load cpptools debugger integration
(require 'dap-cpptools)
(setq dap-cpptools-extension-version "1.5.1")
;; Register Rust debug template for cpptools
(with-eval-after-load 'dap-cpptools
;; Add a template specific for debugging Rust programs.
;; It is used for new projects, where I can M-x dap-edit-debug-template
(dap-register-debug-template "Rust::CppTools Run Configuration"
(list :type "cppdbg"
:request "launch"
:name "Rust::Run"
:MIMode "gdb"
:miDebuggerPath "rust-gdb"
:environment []
:program "${workspaceFolder}/target/debug/kvmapi"
:cwd "${workspaceFolder}"
:console "external"
:dap-compilation "cargo build"
:dap-compilation-dir "${workspaceFolder}")))
(setq dap-auto-configure-features (remove 'controls dap-auto-configure-features))
(map! :map dap-mode-map
:leader
(:prefix ("d" . "dap")
:desc "debug" "d" #'dap-debug
:desc "debug last" "l" #'dap-debug-last
:desc "debug recent" "r" #'dap-debug-recent
:desc "continue" "c" #'dap-continue
:desc "next" "n" #'dap-next
:desc "step in" "i" #'dap-step-in
:desc "step out" "o" #'dap-step-out
:desc "hydra" "h" #'dap-hydra
:desc "restart" "R" #'dap-debug-restart
:desc "eval" "e" #'dap-eval
:desc "eval region" "E" #'dap-eval-region
:desc "eval at point" "s" #'dap-eval-thing-at-point
:desc "add expr" "a" #'dap-ui-expressions-add
:desc "remove expr" "x" #'dap-ui-expressions-remove
:desc "toggle breakpoint" "b" #'dap-breakpoint-toggle
:desc "bp condition" "B" #'dap-breakpoint-condition))
See above you will have to setup your personal templates for each project. Ensure you know if you are using gdb or llmi for debugging purposes
Then just run 'dap-debug' (SPC d d) and you can execute your code