How do you navigate 100+ lines of python code in lsp-mode? reddit / emacs ---------------------------------------------------------------------- omeow · 2022-06-16 09:04 Ideally - I would like to quickly jump up/down to functions, class, possible get some type hints (if available) for variables. - If possible fold/unfold blocks (function blocks probably) like in org mode. I recently got \`lsp-mode\` to work. So, if something is available in this eco-system that will be great. Otherwise I am open to other suggestions. 'Elpy` has this functionality but it is very slow and I notice a lag -- which I cannot live with. Thank you for your suggestions (and please feel free to describe/share your tools)!!!! ---------------------------------------------------------------------- NoisyFrequency · 2022-06-16 10:07 For navigating definitions, you can use `lsp-ui-imenu` [see here](https://github.com/emacs-lsp/lsp-ui#lsp-ui-imenu), which will create an outline of the code, you need to install `lsp-ui` to use it. I personally prefer to use `xref-find-definitions` to lookup where a function was defined. For code folding, there is `hs-minor-mode` (hideshow, which is included in Emacs) that lets you fold and unfold blocks. ---------------------------------------------------------------------- diamondnbond · 2022-06-16 11:33 I like imenu-list and counsel imenu list :) ---------------------------------------------------------------------- recencyeffect · 2022-06-16 11:43 Lsp-ui-menu was already mentioned, I'd like to add narrow to defun `C-x n d` that is sometimes useful in large files. ---------------------------------------------------------------------- ExistingProgram3883 · 2022-06-16 13:05 I recommend using [consult-lsp](https://github.com/gagbo/consult-lsp) and its function consult-lsp-file-symbols. ---------------------------------------------------------------------- konrad1977 · 2022-06-16 13:05 I am not using LSP but `dumb-jump` works great. ---------------------------------------------------------------------- pathemata · 2022-06-16 13:15 outline-minor-mode works, but it is not perfect and sometimes annoying. ---------------------------------------------------------------------- FrozenOnPluto · 2022-06-16 13:36 Random stream of consiousness pre-coffee :) LSP enables python mode, which has things like C-M-a (jump to begin of block / def) IIRC, among many others. I think the challenge is many options and methods, so which are they? which to use? which to bind? I find myself using of course dozens and dozens of different keystrokes and options, but for lesser used I tend to make my own helpers.. I use hydra menus (pretty hydra iirc), and have set up a couple master keys that pop up top levcel hydras, and then have those hydras pop up sub hydras and/or make function calls; I commonly have some hydra entries that toggle things on and off (such as lsp- treemacs-symbols) to show a panel of vars and defs and such, and also to dismiss that; I so rarely use that sort of thing that I will never remember the keybind or function name, so I just bury it in one of my personal menus. So for me its