Take your functions and easily refactor them while keeping an eye on the initial implementation
GPL-3.0 License
Seamlessly refactor code chunks within your projects while keeping an eye on the initial implementation. By providing an intuitive interface, it simplifies the process of modifying functions, variables, structs, enums, and other code elements without disrupting your workflow.
[!IMPORTANT]
- The plugin is in early development, so it may not work with certain languages. If your
language is not supported, please create an issue.- For the same reason above, you may encounter a bug at some point (I hope you don't!). Please
report it with reproduction steps if possible.
:Rocks install exemplum.nvim
require("lazy").setup({
{
"NTBBloodbath/exemplum.nvim",
dependencies = { "NTBBloodbath/logging.nvim" },
},
})
[!NOTE]
If you are going for lazy-loading, it would be recommended to load by
filetype
. Below you can find the languages that are currently supported.
exemplum.nvim
is configured through the vim.g.exemplum
global variable. The following is the
default configuration:
---@type ExemplumConfig
vim.g.exemplum = {
window = {
style = "split",
border = "single",
},
disable_diagnostics = false,
}
The configuration is annotated, so you should have a good experience editing it.
exemplum.nvim
does not require a setup
function to work and automatically creates the :Exemplum
command when loaded.
:Exemplum
command to refactor the nearest code chunk under:Exemplum <code_type>
to refactor the code_type
:Exemplum function
.In case you want to silence your LSP diagnostics in the refactoring buffer, you can invoke the
command by adding a bang (!
) at the end of it, e.g. :Exemplum! function
.
Currently available code_type
arguments:
function
variable
struct
enum
After performing a refactoring you can either save the buffer so it will be closed and the changes
will be applied or you can close the buffer using :q
to close it without applying the changes.
[!NOTE]
- Exemplum works with a
look_behind
method. Therefore, it will always iterate over the current
node and the parent node of the current node to find the code chunk.- The inference method (
:Exemplum
without arguments) depends heavily on the current position of
your cursor, and prioritizes variables over functions.
C
C++
Go
Lua
(does not support enum
s)Rust
Python
This project is licensed under the GNU General Public License v3 (GPLv3). You can find the license details in the LICENSE file.