reddit / emacs

Visual code folding?

FaustBargain · 2022-11-27 21:54
I'm trying to give doom emacs a try. I'm usually on vscode. One thing holding me back is I absolutely need a visual indicator for folding codeblocks. ​ like this [https://user-images.githubusercontent.com/1507950/41067697-88af8508-69b4-11e8-8068-0ddd5c3af322.png](https://user-images.githubusercontent.com/1507950/41067697-88af8508-69b4-11e8-8068-0ddd5c3af322.png) ​ I'm mostly in c++. what's my best option?
[deleted] · 2022-11-27 22:11
[deleted]
FaustBargain · 2022-11-27 22:13
uhm every subheading is empty ....
FaustBargain · 2022-11-27 22:51
ok so I found this [https://github.com/DarthFennec/highlight-indent-guides](https://github.com/DarthFennec/highlight-indent-guides) it told me to install with `M-x highlight-indent-guides-mode` then it said to add (add-hook 'prog-mode-hook 'highlight-indent-guides-mode) and (setq highlight-indent-guides-method METHOD)Where METHOD is either 'fill, 'column, 'character, or 'bitmap. ​ now I'm brand new to emacs so I had no idea WHERE to add these, but eventually guessed the \~/.doom.d/custom.el and then reloaded with `SPC h r r` and that seemed to work. not sure if this is smart enough to understand actual code blocks or if it's just using indents, but it's a start
VAlUgap · 2022-11-27 23:02
There is https://github.com/emacs-tree-sitter/ts-fold it requires tree-sitter.
FaustBargain · 2022-11-27 23:29
hmm I wish it had an example with a lot of nested blocks. I'll look into it though. Thanks!
amizya · 2022-11-27 23:42
man doom documentation is absolute rubbish, i’m sorry for the term but it looks like it’s not a beginners friendly oriented
Weekly_Bathroom_101 · 2022-11-28 00:02
This is a great dig.
m_sachs · 2022-11-28 00:11
The docs are being completely rewritten. To enable this module, just uncomment (remove the semicolons at the beginning of the line) the 'indent-guides' line under the ':ui' module in '.doom.d/init.el', then restart Emacs. Do no add stuff to the 'custom.el' file - Doom does not (officially) support it (and it wouldn't be the file you'd be looking for even if it did). Do read Doom's general documentation, it is quite good. The modules' docs aren't always very satisfactory, but that's being worked on.
FaustBargain · 2022-11-28 00:37
well i tried commenting out what I had put and uncommenting that line but now I have some error that I can't decipher so i tried nuking my .doom.d folder and reinstalling, but it's still there ​ `--*- mode: compilation; default-directory: "~/.emacs.d/" -*-` `Comint started at Sun Nov 27 18:30:29` `"/home/sirus/.emacs.d/bin/doom" sync -e` `x There was an unexpected runtime error` `Message: Wrong type argument` `Details: (stringp afternoon-theme)` `Backtrace:` `(intern afternoon-theme)` `((closure ((package . gnu-elpa-mirror) use-package-pre-ensure-function use-package-keywords use-package-ensure-function use-package-defaults package-selected-packages package--builtins t) (it) (intern (car it))) (afternoon-theme :url "https://github.com/osener/emacs-after...` `(cl--position gnu-elpa-mirror ((afternoon-theme :url "https://github.com/osener/emacs-afternoon-theme" :ignored-files ("*.png")) (alect-themes :url "https://github.com/alezost/alect-themes" :ignored-files ("LICENSE" "tests" "Makefile" "colors")) (ample-theme :url "https:/...` `(cl-position gnu-elpa-mirror ((afternoon-theme :url "https://github.com/osener/emacs-afternoon-theme" :ignored-files ("*.png")) (alect-themes :url "https://github.com/alezost/alect-themes" :ignored-files ("LICENSE" "tests" "Makefile" "colors")) (ample-theme :url "https://...` `(cl-find gnu-elpa-mirror ((afternoon-theme :url "https://github.com/osener/emacs-afternoon-theme" :ignored-files ("*.png")) (alect-themes :url "https://github.com/alezost/alect-themes" :ignored-files ("LICENSE" "tests" "Makefile" "colors")) (ample-theme :url "https://gith...` `(straight-recipes-nongnu-elpa--translate (cl-find package (straight-recipes-nongnu-elpa--recipes) :key #'(lambda (it) (intern (car it)))))` `(straight-recipes-nongnu-elpa-retrieve gnu-elpa-mirror)` `(apply straight-recipes-nongnu-elpa-retrieve gnu-elpa-mirror)` `(let ((default-directory (if local-repo (straight--repos-dir local-repo) default-directory)) (func (intern (format "straight-recipes-%S-%S" name method)))) (apply func args))` `(let* ((--cl-rest-- recipe) (local-repo (car (cdr (plist-member --cl-rest-- ':local-repo))))) (let ((default-directory (if local-repo (straight--repos-dir local-repo) default-directory)) (func (intern (format "straight-recipes-%S-%S" name method)))) (apply func args)))` `(let ((recipe (straight--convert-recipe name cause))) (let* ((--cl-rest-- recipe) (local-repo (car (cdr (plist-member --cl-rest-- ':local-repo))))) (let ((default-directory (if local-repo (straight--repos-dir local-repo) default-directory)) (func (intern (format "straight...` `(let ((straight--recipe-repository-stack (cons name straight--recipe-repository-stack))) (straight-use-package name nil nil cause) (let ((recipe (straight--convert-recipe name cause))) (let* ((--cl-rest-- recipe) (local-repo (car (cdr (plist-member --cl-rest-- ':local-rep...` `! Wrote extended backtrace to ~/.emacs.d/.local/logs/cli.doom.221127183030.159476.error` `✓ Finished in 0.30462s`
Dj_Optimus_Rhyme · 2022-11-28 00:38
[hideshow](https://www.emacswiki.org/emacs/HideShow) is pretty great, and comes preinstalled with stock emacs. Personally I found the default bindings a bit unergonomic and rebound the toggle function to `C-c TAB`.
FaustBargain · 2022-11-28 00:47
shit. i tried uninstalling emacs and reinstalling and I get the same error
LaCachoraLoca · 2022-11-28 01:12
Try to temporarily use the default doom theme. This error seems unrelated to ts-fold.
FaustBargain · 2022-11-28 01:27
the theme is the default one. i uninstalled doom emacs and emacs and reinstalled both and the error persists.
LaCachoraLoca · 2022-11-28 02:14
Could you share your config.el file and the output of running \~/.emacs.d/bin/doom doctor on the terminal? Edit: Also, unless you deleted the .emacs.d folder prior to reinstallation, you might be using the same files as before. You can also try to rebuild (\~/.emacs.d/bin/doom build).
FaustBargain · 2022-11-28 02:52
I did delete the .emacs.d folder prior to reinstallation this is my config.el it should be the default https://paste2.org/E2z3KYN4 `[sirus@serenitynow ~]$ ~/.emacs.d/bin/doom doctor` `The doctor will see you now...` `> Checking your Emacs version...` `> Checking for Doom's prerequisites...` `> Checking for Emacs config conflicts...` `> Checking for great Emacs features...` `> Checking for private config conflicts...` `> Checking for stale elc files...` `x There was an unexpected runtime error` `Message: File is missing` `Details: ("Opening directory" "No such file or directory" "/home/sirus/.emacs.d/.local/straight/build-28.2")` `Backtrace:` `(file-name-all-completions "" "/home/sirus/.emacs.d/.local/straight/buil...` `(directory-files-recursively "/home/sirus/.emacs.d/.local/straight/build...` `(let ((--dolist-tail-- (directory-files-recursively dir "\\.elc$"))) (wh...` `(elc-check-dir "/home/sirus/.emacs.d/.local/straight/build-28.2")` `(let nil (doom-print (doom-print--format "The doctor will see you now......` `((closure (t) (cli alist) (let nil (doom-print (doom-print--format "The ...` `(funcall (closure (t) (cli alist) (let nil (doom-print (doom-print--form...` `(doom-cli-execute #s(doom-cli ("doom" "doctor") nil (("SUMMARY" . "Diagn...` `(let ((cli x16) (bindings x17)) (doom-cli-execute cli bindings))` `(let* ((x16 (car-safe x15)) (x17 (cdr-safe x15))) (let ((cli x16) (bindi...` `(progn (ignore (consp x15)) (let* ((x16 (car-safe x15)) (x17 (cdr-safe x...` `(let ((x15 (car --dolist-tail--))) (progn (ignore (consp x15)) (let* ((x...` `Setting current directory: No such file or directory, /home/sirus/.emacs.d/.local/straight/build-28.2`
sbudnik2 · 2022-11-28 03:12
This seems like an open issue, but the identified workaround was fine for me. https://github.com/doomemacs/doomemacs/issues/6960
FaustBargain · 2022-11-28 03:50
ok that got rid of the error. so I setup my init again from scratch. I uncommented the indent-guides and there are no more lines in my code blocks
FaustBargain · 2022-11-28 04:05
I can't find any visual example of how it shows what is a code block
FaustBargain · 2022-11-28 04:34
ok to the init I added (add-hook 'prog-mode-hook 'indent-guide-global-mode) (setq indent-guide-recursive t) and that seems to work
Subtielens · 2022-11-28 05:22
On a side note: custom.el is an automatic generated file by emacs where it stores changes the user makes in the configuration. Because it is auto generated it is usually not a good idea to add your own configurations there. Doom offers its own personal config files, which you can access with SPC f P. I believe you can add it to config.el.
FaustBargain · 2022-11-28 06:29
i was using the one in .doom.d/
fabiopapa · 2022-11-28 06:34
Hi! Doom user here. When you enable a new module in init.el, you need to run `doom upgrade` from the command line and then restart emacs. init.el is where you enable/disable doom’s modules. You shouldn’t add anything else to that file. If you need to install new packages, you do that in package.el. If you need to configure those packages (or anything else) you put that in config.el. The comment at the bottom of config.el is somewhat helpful. Best of luck!
thiscarhasfourtires · 2022-11-28 06:36
> now I'm brand new to emacs so I had no idea WHERE to add these, but eventually guessed the ~/.doom.d/custom.el While that works, that is not the purpose of `custom.el`. If you're using Doom, 99% of your settings should be inside `config.el`. On Doom, you install packages by adding them to `packages.el` (refer to the comments on this file for instructions) and running `$ doom sync` afterward. Alternatively, you can run `M-x doom/reload` from Emacs. This will install the package and reload the init so that it becomes active. Even though that is not actively recommended, it works most of the time and removes the need to restart Emacs. If the package you want is part of a module, you'd probably be best served by using the module instead. Modules are listed, activated, and flagged on `init.el`. Package configurations (including Emacs and Doom builtins) should be on `config.el`, preferably under `use-package!` blocks. [Relevant Doom documentation](https://github.com/doomemacs/doomemacs/blob/master/docs/getting_started.org#package-management). `use-package!` is a macro over [use-package](https://github.com/jwiegley/use-package), and respect its syntax, with a few additions. [Useful reference on use-package keywords](https://jwiegley.github.io/use-package/keywords/). Additionally, see the Emacs help for the function with `M-x helpful-callable` followed by `use-package!` and then press `enter`. If you need constant assistance, I advise you to get on [Doom's Discord server](https://discord.gg/qvGgnVx). /r/DoomEmacs is not super active but can be useful as well. Doom's configurations framework is efficient, logical, and reliable. However, if you find it too overwhelming, it may be a good idea to just start with a barebone Emacs and make heavy use of the [customize interface](https://www.gnu.org/software/emacs/manual/html_node/emacs/Easy-Customization.html). You can always move to Doom later if you want.
JohnDoe365 · 2022-11-28 07:52
As tree-sitter has been commited into master a word of caution is necessary, as this ts-fold relies on emacs-tree-sitter, which to my understanding is incompatible to the integrated support?
JohnDoe365 · 2022-11-28 07:54
That's the thing the OP is after. I use it t0o, it's performance is wanting though and becomes quite noticeable when folding on eg. larger json files. I hope h-i-g will profit from improved overlay code in Emacs 29.
Icommentedtoday · 2022-11-28 08:45
Correct
LaCachoraLoca · 2022-11-28 13:18
Did "\~/.emacs.d/bin/doom install" return any error? It looks to me like installation did not finish cleanly. straight is not installed, it is the first package installed, used to install most others.
Nathoufresh · 2022-11-28 17:37
For indentation guides: Modify init.el in ~/.doom.d uncomment the line starting with "indent-guides". Now stop emacs and run doom sync. Restart emacs and enjoy indentation guides! There's also a module for code folding but I'm not familiar with. Do not forget to check the docs on doomemacs' github.
FaustBargain · 2022-11-28 21:46
>I had to add > >(add-hook 'prog-mode-hook 'indent-guide-global-mode) (setq indent-guide-recursive t) > >to get that to work
Dj_Optimus_Rhyme · 2022-11-29 13:04
There are examples in that link, but the TL;DR is that it replaces blocks with `...`. So the following ```c int foo() { int x = 0; return x; } ``` is folded to ```c int foo() {...} ``` when collapsed. As for what it considers foldable? This will depend on the language. But it generally folds all compound statements. In C-like languages this means anything surrounded by `{` and `}`, in python this corresponds to any indented block.
FaustBargain · 2022-11-29 16:51
I don't really want the ability to fold, I really just need the indent highlight guide for it to show what's foldable. it helps me quickly see which blocks are together
Trout_Tickler · 2022-11-30 21:46
`doom sync`*
fabiopapa · 2022-12-01 01:16
Don upgrade does the doom sync but also installs any packages that may have been added. I figure for a newer doom user it’s easier to remember one commands that does both things.
Trout_Tickler · 2022-12-01 13:41
doom sync does both. Upgrade upgrades the version of doom to include any recent changes. They do different things and you're giving confusing, wrong advice to new users :)
LaCachoraLoca · 2022-12-01 23:17
If any person finds this, it is actually a reported bug https://github.com/doomemacs/doomemacs/issues/6960#issuecomment-1327915486