someone-stole-my-name / yaml-companion.nvim

Get, set and autodetect YAML schemas in your buffers.
MIT License
203 stars 18 forks source link

Fix UI no selection and no client #17

Closed mosheavni closed 1 year ago

mosheavni commented 1 year ago

Get client

With the previous way of getting the client, this error would prompt:

E5108: Error executing lua .../Downloads/nvim-macos/share/nvim/runtime/lua/vim/lsp.lua:1801: attempt to index local 'client' (a nil value)
stack traceback:
        .../Downloads/nvim-macos/share/nvim/runtime/lua/vim/lsp.lua:1801: in function 'get_active_clients'
        .../yaml-companion.nvim/lua/yaml-companion/lsp/requests.lua:29: in function 'get_all_jsonschemas'
        ...tart/yaml-companion.nvim/lua/yaml-companion/lsp/util.lua:9: in function 'get_all_yaml_schemas'
        ...art/yaml-companion.nvim/lua/yaml-companion/select/ui.lua:20: in function 'open_ui_select'
        ...er/start/yaml-companion.nvim/lua/yaml-companion/init.lua:36: in function 'open_ui_select'
        [string ":lua"]:1: in main chunk

After the change, this error never pops. (after I finished this PR, I saw that there's another pending PR #14 for the same thing, so I took his code, which looks better than mine, I adopted it, @joshfrench you are welcome to take the credit for that) Please merge #14, it's important!

To reproduce

Must run REALLY fast:

vim foo.yaml
:lua require('yaml-companion').open_ui_select()

UI select no input

If a user clicks escape when the UI select is open, it will prompt an error:

E5108: Error executing lua ...art/yaml-companion.nvim/lua/yaml-companion/select/ui.lua:15: attempt to index local 'schema' (a nil value)
stack traceback:
        ...art/yaml-companion.nvim/lua/yaml-companion/select/ui.lua:15: in function 'on_choice'
        ...er/start/dressing.nvim/lua/dressing/select/telescope.lua:117: in function <...er/start/dressing.nvim/lua/dressing/select/telescope.lua:116>
        ...packer/start/telescope.nvim/lua/telescope/actions/mt.lua:75: in function 'key_func'
        ...k/packer/start/telescope.nvim/lua/telescope/mappings.lua:338: in function 'execute_keymap'
        [string ":lua"]:1: in main chunk

After the change, this error never pops.

To reproduce:

:lua require('yaml-companion').open_ui_select()
*Press Escape*

Weird "result" entry

For some weird reason, my (latest) yaml-language-server returns a result that looks like this:

{
    fromStore = false,
    uri = "result",
    usedForCurrentFile = false
  }

So I'm filtering any result that doesn't match ^https? image

mosheavni commented 1 year ago

@someone-stole-my-name ?