zioroboco / nu-ls.nvim Goto Github PK
View Code? Open in Web Editor NEWA null-ls source providing language server features for the nushell language in neovim
License: MIT License
A null-ls source providing language server features for the nushell language in neovim
License: MIT License
Currently we're not requesting diagnostics (and other methods?) spanning multiple input files.
nushell supports this: nushell/nushell#8857
null-ls does too: https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/MAIN.md#multi-file-generators
(I haven't personally tried either)
As of nu v0.79 having been released (and before, but I wasn't sure how far along this feature was), the markdown-like return value from nu --ide-hover
isn't being rendered correctly in hovers. Currently the text returned from nu is just being displayed verbatim in neovim (which works well enough, but it's not pretty).
The syntax is a bit funny with lots of code fences that I can't quite make sense of (and neither can neovim's markdown rendering functions under vim.lsp
). This might be a known format for returning LSP hover text, I simply haven't read the docs closely enough yet.
Here is a dump of the output from running this on the let
command, for me (or anyone) to have a think about how to correctly parse and render this:
```
### Signature
```
let {flags} <var_name> <initial_value>
```
### Parameters
`var_name: any` - variable name
\
`initial_value: any` - equals sign followed by value
### Flags
`-h`, `--help` - Display the help message for this command
### Input/output
```
nothing | nothing
```
### Usage
Create a variable and give it a value.
### Extra usage:
This command is a parser keyword. For details, check:
https://www.nushell.sh/book/thinking_in_nu.html
### Example(s)
```
```
Set a variable to a value
```
let x = 10
```
Set a variable to the result of an expression
```
let x = 10 + 100
```
Set a variable based on the condition
```
let x = if false { -1 } else { 1 }
Currently:
With these made more generic (somehow), we could start running checks in GitHub actions.
(raised in #7)
I believe this could be implemented using code actions in null-ls, but it's not obvious if there would then be a way to invoke it from neovim's built in vim.lsp.buf.definition()
function...
hello there @zioroboco ๐ ๐
if you want to reduce the size of your README
a bit, i've moved parts of your Syntax highlighting? section to the main nushell/treesitter-nu
in nushell/tree-sitter-nu#8 ๐
In lieu of actually writing this up in the readme, some quick thoughts:
There isn't currently a stand-alone nushell language server โ the one in the vscode extension is more or less coupled to the implementation of that extension, and after poking around a bit, I concluded that there are probably better uses of time than trying to extract it (see also: nushell/vscode-nushell-lang#117)
Maintaining a null-ls.nvim source in the meantime (i.e. this repo) means essentially maintaining another language server implementation (one which runs directly within the neovim process).
This is a small duplication of effort between neovim and vscode, but it seems like a fine way to bridge this gap for the moment. It's based on the same features of the nushell binary that the vscode extension is using, so most of the heavy lifting was already done. But this split focus obviously isn't ideal.
Since there's basically a reference implementation for the LSP methods in nushell/nushell already, I think writing a stand-alone language server in rust doesn't seem outrageously difficult, but I'll keep this repo going in the meantime.
Completing str tr
results in str str trim
(for example).
Instead, it should be removing any already-inserted partial match (i.e. the thing that the completion was generated against) from the result before inserting. I'm not sure if this is possible from the perspective of a null-ls completion source, because we're just returning lists of strings and not actually writing them to the buffer. ๐ค
We could remove the partially completed parent command from the completion list as well, but I think that would make the actual command being suggested less obvious. Not sure if there's another option, though.
Since the introduction of the debounce timer for completions in #7, typing quickly can sometimes cause nu to return an error like the following:
thread 'main' panicked at 'assertion failed: self.is_char_boundary(idx)', /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/alloc/src/string.rs:1532:9
This looks similar to errors I've seen before when asking nu to generate completions for a cursor position beyond the end of the file.
I suspect this might be caused by a race condition, likely from differences between the temporary file that nu's being asked to generate completions against and the cursor position reported by null-ls.
hello there ๐ ๐
i've been trying nu-ls.nvim
on and off for a few days now and it looks a bit slow to me...
neovim hangs a tiny little on each character change ๐ค
did you notice the same behaviour @zioroboco? ๐ข
here are the changes i use in my kickstart.nvim
config to enable it ๐
diff --git a/lua/custom/plugins/null-ls.lua b/lua/custom/plugins/null-ls.lua
new file mode 100644
index 0000000..fcaaa45
--- /dev/null
+++ b/lua/custom/plugins/null-ls.lua
@@ -0,0 +1,10 @@
+return {
+ "jose-elias-alvarez/null-ls.nvim",
+ config = function ()
+ require("null-ls").setup {
+ sources = {
+ require("nu-ls"),
+ },
+ }
+ end
+}
hello there ๐ ๐
i wanted to install this plugin to try it out and give you some feedback, but i'm having some trouble ๐ฎ
i've tried to use the snippet you give in the README
, i.e.
return {
"jose-elias-alvarez/null-ls.nvim",
config = function ()
require("null-ls").setup {
sources = {
require("nu-ls"),
},
}
end
}
in my lua/custom/plugins/null-ls.lua
(my config is based on the kickstart
framework for neovim)
i've also tried
return {
"jose-elias-alvarez/null-ls.nvim",
config = function ()
require("null-ls").setup {
sources = {
require("zioroboco/nu-ls.nvim"),
},
}
end
}
but i get the same error
Failed to run `config` for null-ls.nvim
/home/amtoine/.config/nvim/lua/custom/plugins/null-ls.lua:6: module 'nu-ls' not found:
^Ino field package.preload['nu-ls']
cache_loader: module nu-ls not found
cache_loader_lib: module nu-ls not found
^Ino file './nu-ls.lua'
^Ino file '/usr/share/luajit-2.1.0-beta3/nu-ls.lua'
^Ino file '/usr/local/share/lua/5.1/nu-ls.lua'
^Ino file '/usr/local/share/lua/5.1/nu-ls/init.lua'
^Ino file '/usr/share/lua/5.1/nu-ls.lua'
^Ino file '/usr/share/lua/5.1/nu-ls/init.lua'
^Ino file './nu-ls.so'
^Ino file '/usr/local/lib/lua/5.1/nu-ls.so'
^Ino file '/usr/lib/lua/5.1/nu-ls.so'
^Ino file '/usr/local/lib/lua/5.1/loadall.so'
# stacktrace:
- ~/.config/nvim/lua/custom/plugins/null-ls.lua:6 _in_ **config**
i probably just don't know and understand how to install a null-ls
plugin, but am i missing something?
cheers โจ
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.