Skip to content

Commit

Permalink
add completion to the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
benlubas committed Jul 8, 2024
1 parent 48f92cc commit 0d90e08
Showing 1 changed file with 37 additions and 13 deletions.
50 changes: 37 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# neorg-interim-ls

Rename files and headers in your norg files without breaking links in the rest of the workspace.
Neorg's missing language server.

- Rename files and headers in your norg files without breaking links in the rest of the workspace
- Get neorg completions without needing an auto completion plugin

---

Expand All @@ -17,10 +20,13 @@ Relative file links like `{/ ./path/to/file.txt}` are also changed when a file i
Moving a file to a location that already exists will fail with an error. Moving a file to a folder
that doesn't exist will create the folder.

Additionally, this plugin provides a completion engine for Neorg that allows anyone to get Neorg
completions (not just those using `nvim-cmp` or `coq-nvim`).

## Limitations

- Links that include a file path to their own file (ie. `{:path/to/blah:}` while in `blah.norg`)
are not supported. But like, just don't do that.
- Links that include a file path to their own file (ie. `{:path/to/blah:}` while in `blah.norg`)
are not supported in refactoring operations. But like, just don't do that.

## Install

Expand All @@ -30,9 +36,11 @@ Install this plugin the way you would any other, and load it by adding this to y
["external.interim-ls"] = {},
```

There is no config. Keybinds should be setup by you in an autocommand on the `LspAttach` event.
Please note the only action you will need for this LS is the rename action, but this autocommand is
used for _all_ of your configured language servers.
## Config

There is no additional Neorg config for this module. Keybinds should be setup by you in an
autocommand on the `LspAttach` event. Please note the only action you will need for this LS is the
rename action, but this autocommand is used for _all_ of your configured language servers.

```lua
vim.api.nvim_create_autocmd("LspAttach", {
Expand All @@ -48,18 +56,34 @@ vim.api.nvim_create_autocmd("LspAttach", {
local opts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)

-- ... other lsp mappings
-- ... your other lsp mappings
end
})
```

### Completion

First ensure that you're able to get LSP completions in some way. This will vary by completion
plugin. For nvim-cmp you will need the `nvim-cmp-lsp` source. For mini-completion things should work
out of the box. If you're using nvim's building omnifunc, I trust you know what you're doing.

Then, configure Neorg's completion module like this:

```lua
["core.completion"] = {
config = { engine = { module_name = "external.lsp-completion" } },
},
```

## Usage

This plugin can be used just like any other LSP:
- rename a heading: done with `:h vim.lsp.buf.rename()`
- rename/move a file: handled by `willRename` which is supported by some file manager plugins such
as [Oil.nvim](https://github.com/steavearc/oil.nvim)
Refactoring works just like a normal LSP:

- rename a heading: done with `:h vim.lsp.buf.rename()`
- rename/move a file: handled by `willRename` which is supported by some file manager plugins such
as [Oil.nvim](https://github.com/steavearc/oil.nvim)

Additionally, there are Neorg commands that that can accomplish the same things (though they are less convienient):
- `:Neorg lsp rename file`
- `:Neorg lsp rename heading`

- `:Neorg lsp rename file`
- `:Neorg lsp rename heading`

0 comments on commit 0d90e08

Please sign in to comment.