

GitHub - ThePrimeagen/refactoring.nvim: The Refactoring library based off the Re...
source link: https://github.com/ThePrimeagen/refactoring.nvim
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

WARNING
There will be some inevitable churn for the next week as I settle on the api!
This is a WORK IN PROGRESS repo :)
Things todo
- I want to write tests for a bunch of stuff.
- stability and profitability
refactoring.nvim
The Refactoring library based off the Refactoring book by Martin Fowler
Setup
Requirements:
- Treesitter
- Plenary
Basic Setup
Packer setup:
use { "ThePrimeagen/refactoring.nvim", requires = { {"nvim-lua/plenary.nvim"}, {"nvim-treesitter/nvim-treesitter"} } }
Example Config:
local refactor = require("refactoring") refactor.setup() -- telescope refactoring helper local function refactor(prompt_bufnr) local content = require("telescope.actions.state").get_selected_entry( prompt_bufnr ) require("telescope.actions").close(prompt_bufnr) require("refactoring").refactor(content.value) end -- NOTE: M is a global object -- for the sake of simplicity in this example -- you can extract this function and the helper above -- and then require the file and call the extracted function -- in the mappings below M = {} M.refactors = function() local opts = require("telescope.themes").get_cursor() -- set personal telescope options require("telescope.pickers").new(opts, { prompt_title = "refactors", finder = require("telescope.finders").new_table({ results = require("refactoring").get_refactors(), }), sorter = require("telescope.config").values.generic_sorter(opts), attach_mappings = function(_, map) map("i", "<CR>", refactor) map("n", "<CR>", refactor) return true end }):find() end vim.api.nvim_set_keymap("v", "<Leader>re", [[ <Cmd>lua require('refactoring').refactor('Extract Function')<CR>]], {noremap = true, silent = true, expr = false}) vim.api.nvim_set_keymap("v", "<Leader>rf", [[ <Cmd>lua require('refactoring').refactor('Extract Function To File')<CR>]], {noremap = true, silent = true, expr = false}) vim.api.nvim_set_keymap("v", "<Leader>rt", [[ <Cmd>lua M.refactors()<CR>]], {noremap = true, silent = true, expr = false})
Recommend
-
92
Files Permalink Latest commit message...
-
94
nvim-nim Nim support for vim and advanced support for neovim. Still in heavy development. Features Asynchronous Up to date syntax highlighting Normal vim highlight More intelligent highlig...
-
53
GitHub is where people build software. More than 28 million people use GitHub to discover, fork, and contribute to over 85 million projects.
-
54
NVIM v0.4.0 · neovim/neovim@e2cc5fe · GitHub
-
61
README.md fzf ❤️ coc.nvim Use fzf instead of coc...
-
348
nvim-compe Auto completion plugin for nvim. Table Of Contents Concept Lua source & Vim source Better matching algorithm Support LSP completion features (trigger character, isIncomp...
-
21
Files Permalink Latest commit message Commit time
-
7
js2-refactor.el A JavaScript refactoring library for emacs. This is a collection of small refactoring functions to further the idea of a JavaScript IDE in Emacs that started with js2-mode. Change in 0.8.0 Add...
-
5
Files Permalink Latest commit message Commit time
-
4
Sort lines based on a column in Vim/Nvim2021-12-21Nvim224 words 2 mins read 116 times readI have a file where each line has several comma-separated ite...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK