Skip to content

Conversation

iainlane
Copy link

@iainlane iainlane commented Apr 9, 2025

See the individual commits and cherry-pick/update them as needed - PR is just for convenience.

iainlane added 9 commits April 9, 2025 08:29
This makes formatting consistent across different users.
Add a `key_prefix` string, a `keys` table and a `setup_mappings` boolean
to the options to allow key mappings to be customised or switched off.
User-provided mappings are merged with defaults, which allows individual
fields to be updated.
Just a small tidy up which removes some code from the setup function.
Adding descriptions to the commands means that various things like
`cmp` or `which-key` can pick them up and show them to the user.
The current setup is giving

```
Failed to run `config` for nvim-jsonnet

...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:387: module 'jsonnet' not found:
    no field package.preload['jsonnet']
    cache_loader: module 'jsonnet' not found
    cache_loader_lib: module 'jsonnet' not found
    no file './jsonnet.lua'
    no file '/opt/homebrew/share/luajit-2.1/jsonnet.lua'
    no file '/usr/local/share/lua/5.1/jsonnet.lua'
    no file '/usr/local/share/lua/5.1/jsonnet/init.lua'
    no file '/opt/homebrew/share/lua/5.1/jsonnet.lua'
    no file '/opt/homebrew/share/lua/5.1/jsonnet/init.lua'
    no file './jsonnet.so'
    no file '/usr/local/lib/lua/5.1/jsonnet.so'
    no file '/opt/homebrew/lib/lua/5.1/jsonnet.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'

  - ~/.config/nvim/lua/config/lazy.lua:30
  - ~/.config/nvim/init.lua:1
```

when we try to load the plugin using `lazy.nvim`. This is because the
plugin name was `nvim-jsonnet` but we weren't under a `lua` directory
with that name. Moving the files to `lua/nvim-jsonnet` and providing an
`init.lua` file fixes this.
Instead of doing all of the work at initialisation time in the plugin's
`setup` function, add a callback which will be invoked when we enter a
Jsonnet buffer. To prevent it running multiple times, we set a flag
`do_setup` and skip if it's already been run.
This means that we don't expose the `Jsonnet*` commands in other
buffers, as they are not relevant there.
This is a user configuration option, not something a plugin should set.
This commit integrates the layout support from
[`CopilotChat.nvim`][CopilotChat], which some modifications.

There's a new `window` table in the configuration which allows the
layout to be customised.

The job/execution handling is updated a bit to align with this too. Now
we keep a reference to a single buffer around, and track whether it's
visible or hidden etc.

[CopilotChat]: https://github.com/CopilotC-Nvim/CopilotChat.nvim
Just some trivial lint errors that prettier & markdownlint pick up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant