mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-02-07 15:19:04 +00:00
1 line
8.6 KiB
JSON
1 line
8.6 KiB
JSON
{"pageProps":{"metadata":{"date":"\"2021-05-09 17:28:23 +08:00\"","date_modified":"\"2021-07-20 23:31:45 +08:00\"","language":"en","source":""},"title":"Emacs as an IDE","hast":{"type":"root","children":[{"type":"element","tagName":"nav","properties":{"className":"toc"},"children":[{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-1"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"language-server-protocol"},"children":[{"type":"text","value":"Language server protocol"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/editor.emacs.as-ide#language-server-protocol"},"children":[{"type":"text","value":"Language server protocol"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"debug-adapter-protocol"},"children":[{"type":"text","value":"Debug Adapter Protocol"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/editor.emacs.as-ide#debug-adapter-protocol"},"children":[{"type":"text","value":"Debug Adapter Protocol"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The development of Visual Studio Code has led to several improvements that benefitted all editors for implementing IDE-like features: "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/Microsoft/debug-adapter-protocol"},"children":[{"type":"text","value":"Debug Adapter Protocol"}]},{"type":"text","value":" (DAP) and "},{"type":"element","tagName":"a","properties":{"href":"https://microsoft.github.io/language-server-protocol/"},"children":[{"type":"text","value":"Language Server Protocol"}]},{"type":"text","value":" (LSP).\n"}]},{"type":"element","tagName":"h1","properties":{"id":"language-server-protocol"},"children":[{"type":"text","value":"Language server protocol"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The community of Emacs was able to "},{"type":"element","tagName":"a","properties":{"href":"https://emacs-lsp.github.io/lsp-mode/"},"children":[{"type":"text","value":"integrate the protocol"}]},{"type":"text","value":" enabling IDE features to be possible (e.g., autocompletion, Intellisense).\nSetting up LSP consists of installing the "},{"type":"element","tagName":"a","properties":{"href":"https://microsoft.github.io/language-server-protocol/implementors/servers/"},"children":[{"type":"text","value":"language server for a specific language"}]},{"type":"text","value":" and hoping for the best if a community member has implemented LSP support for that language and the editor of choice.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"On Emacs, you simply have to do these things:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Install "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"lsp-mode"}]},{"type":"text","value":" (or enable "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/hlissner/doom-emacs/tree/develop/modules/tools/lsp"},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"tools/lsp"}]}]},{"type":"text","value":" built-in module if you're using Doom Emacs).\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Install the language server of the language/tool before enabling "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"lsp-mode"}]},{"type":"text","value":".\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If the support for the LSP support package for a specific language, enable it (or configure it in your module).\n"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"While certain language servers can be automatically installed with "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"lsp-mode"}]},{"type":"text","value":", it is better to be explicitly installed from the environment.\nNix/Guix environments should be a good application here.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If you're enabling "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"lsp-mode"}]},{"type":"text","value":", there is a chance of encountering an error telling that the current project is not a workspace or something similar.\nYou can bypass it by either setting the folder as a workspace with "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"lsp-workspace-folders-add"}]},{"type":"text","value":" or running "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"lsp"}]},{"type":"text","value":" which will run on a single file "},{"type":"text","value":".\n"}]},{"type":"element","tagName":"h1","properties":{"id":"debug-adapter-protocol"},"children":[{"type":"text","value":"Debug Adapter Protocol"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The same community of "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"lsp-mode"}]},{"type":"text","value":" has gathered together to implement DAP as well.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Setting up DAP is mostly similar to setting up LSP: installing a "},{"type":"element","tagName":"a","properties":{"href":"https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/"},"children":[{"type":"text","value":"debug adapter server for a language"}]},{"type":"text","value":" and hoping for the best if a community member has implemented DAP support for that language and the editor of choice.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"On Emacs, you have to do the following:\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Install "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"dap-mode"}]},{"type":"text","value":" (or add a "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"+dap"}]},{"type":"text","value":" feature to "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"tools/lsp"}]},{"type":"text","value":" if you're using Doom Emacs).\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Install the language server of the language/tool before starting up DAP on Emacs.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Create a debugging template with "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"dap-debug"}]},{"type":"text","value":" or "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"dap-debug-edit-template"}]},{"type":"text","value":" which will let you edit the template before running.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Do the usual debugging stuff (e.g., adding a breakpoint).\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Celebrate in joy as you're one step closer to an Emacs IDE-lite.\n"}]}]}]}]},"backlinks":[]},"__N_SSG":true} |