mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-01-31 01:57:54 +00:00
30 lines
15 KiB
HTML
30 lines
15 KiB
HTML
<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width"/><meta charSet="utf-8"/><title>Emacs as an IDE</title><script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script><script id="MathJax-script" async="" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script><script type="text/x-mathjax-config">
|
|
MathJax = {
|
|
tex: {
|
|
inlineMath: [ ['$','$'], ['\(','\)'] ],
|
|
displayMath: [ ['$$','$$'], ['[',']'] ]
|
|
},
|
|
options = {
|
|
processHtmlClass = "math"
|
|
}
|
|
}
|
|
</script><meta name="next-head-count" content="6"/><link rel="preload" href="/wiki/_next/static/css/52fc2ba29703df73922c.css" as="style"/><link rel="stylesheet" href="/wiki/_next/static/css/52fc2ba29703df73922c.css" data-n-g=""/><noscript data-n-css=""></noscript><link rel="preload" href="/wiki/_next/static/chunks/main-ae4733327bd95c4ac325.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/webpack-50bee04d1dc61f8adf5b.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/framework.9d524150d48315f49e80.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/commons.0e1c3f9aa780c2dfe9f0.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/pages/_app-8e3d0c58a60ec788aa69.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/940643274e605e7596ecea1f2ff8d83317a3fb76.4841a16762f602a59f00.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/pages/%5B%5B...slug%5D%5D-1aa198f87ede1cd0e1dc.js" as="script"/></head><body><div id="__next"><main><h1>Emacs as an IDE</h1><section class="post-metadata"><span>Date: <!-- -->2021-05-09 17:28:23 +08:00</span><span>Date modified: <!-- -->2021-07-20 23:31:45 +08:00</span></section><nav class="toc"><ol class="toc-level toc-level-1"><li class="toc-item toc-item-h1"><a href="/wiki/editor.emacs.as-ide#language-server-protocol" class="toc-link toc-link-h1">Language server protocol</a></li><li class="toc-item toc-item-h1"><a href="/wiki/editor.emacs.as-ide#debug-adapter-protocol" class="toc-link toc-link-h1">Debug Adapter Protocol</a></li></ol></nav><p>The development of Visual Studio Code has led to several improvements that benefitted all editors for implementing IDE-like features: <a href="https://github.com/Microsoft/debug-adapter-protocol">Debug Adapter Protocol</a> (DAP) and <a href="https://microsoft.github.io/language-server-protocol/">Language Server Protocol</a> (LSP).
|
|
</p><h1 id="language-server-protocol">Language server protocol</h1><p>The community of Emacs was able to <a href="https://emacs-lsp.github.io/lsp-mode/">integrate the protocol</a> enabling IDE features to be possible (e.g., autocompletion, Intellisense).
|
|
Setting up LSP consists of installing the <a href="https://microsoft.github.io/language-server-protocol/implementors/servers/">language server for a specific language</a> and hoping for the best if a community member has implemented LSP support for that language and the editor of choice.
|
|
</p><p>On Emacs, you simply have to do these things:
|
|
</p><ul><li><p>Install <code class="inline-code">lsp-mode</code> (or enable <a href="https://github.com/hlissner/doom-emacs/tree/develop/modules/tools/lsp"><code class="inline-code">tools/lsp</code></a> built-in module if you're using Doom Emacs).
|
|
</p></li><li><p>Install the language server of the language/tool before enabling <code class="inline-code">lsp-mode</code>.
|
|
</p></li><li><p>If the support for the LSP support package for a specific language, enable it (or configure it in your module).
|
|
</p></li></ul><p>While certain language servers can be automatically installed with <code class="inline-code">lsp-mode</code>, it is better to be explicitly installed from the environment.
|
|
Nix/Guix environments should be a good application here.
|
|
</p><p>If you're enabling <code class="inline-code">lsp-mode</code>, there is a chance of encountering an error telling that the current project is not a workspace or something similar.
|
|
You can bypass it by either setting the folder as a workspace with <code class="inline-code">lsp-workspace-folders-add</code> or running <code class="inline-code">lsp</code> which will run on a single file <!-- -->.
|
|
</p><h1 id="debug-adapter-protocol">Debug Adapter Protocol</h1><p>The same community of <code class="inline-code">lsp-mode</code> has gathered together to implement DAP as well.
|
|
</p><p>Setting up DAP is mostly similar to setting up LSP: installing a <a href="https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/">debug adapter server for a language</a> and hoping for the best if a community member has implemented DAP support for that language and the editor of choice.
|
|
</p><p>On Emacs, you have to do the following:
|
|
</p><ul><li><p>Install <code class="inline-code">dap-mode</code> (or add a <code class="inline-code">+dap</code> feature to <code class="inline-code">tools/lsp</code> if you're using Doom Emacs).
|
|
</p></li><li><p>Install the language server of the language/tool before starting up DAP on Emacs.
|
|
</p></li><li><p>Create a debugging template with <code class="inline-code">dap-debug</code> or <code class="inline-code">dap-debug-edit-template</code> which will let you edit the template before running.
|
|
</p></li><li><p>Do the usual debugging stuff (e.g., adding a breakpoint).
|
|
</p></li><li><p>Celebrate in joy as you're one step closer to an Emacs IDE-lite.
|
|
</p></li></ul></main></div><script id="__NEXT_DATA__" type="application/json">{"props":{"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},"page":"/[[...slug]]","query":{"slug":["editor.emacs.as-ide"]},"buildId":"Ie9t5zutrXP6Of75Cb5xF","assetPrefix":"/wiki","nextExport":false,"isFallback":false,"gsp":true}</script><script nomodule="" src="/wiki/_next/static/chunks/polyfills-99d808df29361cf7ffb1.js"></script><script src="/wiki/_next/static/chunks/main-ae4733327bd95c4ac325.js" async=""></script><script src="/wiki/_next/static/chunks/webpack-50bee04d1dc61f8adf5b.js" async=""></script><script src="/wiki/_next/static/chunks/framework.9d524150d48315f49e80.js" async=""></script><script src="/wiki/_next/static/chunks/commons.0e1c3f9aa780c2dfe9f0.js" async=""></script><script src="/wiki/_next/static/chunks/pages/_app-8e3d0c58a60ec788aa69.js" async=""></script><script src="/wiki/_next/static/chunks/940643274e605e7596ecea1f2ff8d83317a3fb76.4841a16762f602a59f00.js" async=""></script><script src="/wiki/_next/static/chunks/pages/%5B%5B...slug%5D%5D-1aa198f87ede1cd0e1dc.js" async=""></script><script src="/wiki/_next/static/Ie9t5zutrXP6Of75Cb5xF/_buildManifest.js" async=""></script><script src="/wiki/_next/static/Ie9t5zutrXP6Of75Cb5xF/_ssgManifest.js" async=""></script></body></html> |