@@ -53,6 +53,48 @@ At a high level, the crate provides helpers and data structures which are common
5353environment, such as easy error handling, file reading, serialisation/deserialisation, etc.
5454If you find something lacking, I encourage you to open a PR!
5555
56+ # # Language Server Support
57+
58+ [` rscls` ](https://github.com/MiSawa/rscls/) works as a middle-man LSP between rust-analyzer and
59+ rust-script.
60+ Below are instructions for getting LSP support using Neovim.
61+
62+ First, ensure you have ` rscls` installed.
63+ ` ` ` sh
64+ cargo install rscls
65+ ` ` `
66+
67+ Next, add the following to your configuration. Note this is for Neovim LSP config.
68+
69+ ` ` ` lua
70+ -- Rust script LSP support through rscls
71+ local lsp_configs = require ' lspconfig.configs'
72+ if not lsp_configs.rscls then
73+ lsp_configs.rscls = {
74+ default_config = {
75+ cmd = { ' rscls' },
76+ filetypes = { ' rustscript' },
77+ root_dir = function(fname)
78+ return require' lspconfig' .util.path.dirname(fname)
79+ end,
80+ },
81+ }
82+ end
83+ require ' lspconfig' .rscls.setup {}
84+ ` ` `
85+
86+ Then, when you are wanting LSP support in a Rust file, set the file type to ` rustscript` with a
87+ command.
88+
89+ ` ` ` vim
90+ :set filetype=rustscript
91+ ` ` `
92+
93+ I generally do not bother with LSP support for small scripts, but it comes in handy for more
94+ complex ones!
95+ _Note that it will take a little bit to spool up the server and compile the script._
96+
97+
5698# # Versioning
5799
58100Versioning does not follow semver as would a normal crate.
0 commit comments