-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: automatically setup neo-tree hooks
- Loading branch information
1 parent
c24e7bc
commit a7b56f8
Showing
6 changed files
with
136 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
local M = {} | ||
|
||
---Setup pymple keymaps | ||
---@param keymaps Keymaps | ||
M.setup_keymaps = function(keymaps) | ||
for k, v in pairs(keymaps) do | ||
vim.api.nvim_set_keymap( | ||
"n", | ||
v.keys, | ||
"<cmd>lua require('pymple.api')." .. k .. "()<CR>", | ||
{ | ||
desc = v.desc, | ||
noremap = true, | ||
silent = true, | ||
} | ||
) | ||
end | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,31 @@ | ||
vim.api.nvim_create_user_command("UpdatePythonImports", function(opts) | ||
require("pymple.api").update_imports(opts.fargs[1], opts.fargs[2]) | ||
end, { | ||
desc = "Update all imports in workspace after renaming `source` to `destination`", | ||
nargs = "+", | ||
}) | ||
local utils = require("pymple.utils") | ||
|
||
vim.api.nvim_create_user_command("ResolvePythonImportUnderCursor", function(_) | ||
require("pymple.api").resolve_import() | ||
end, { | ||
desc = "Resolves import for symbol under cursor", | ||
}) | ||
local function handle_error(err) | ||
-- Extract the actual error message without traceback | ||
local error_message = err:match(":%d+: (.+)") | ||
vim.api.nvim_echo({ { error_message or err, "ErrorMsg" } }, true, {}) | ||
end | ||
|
||
local required_binaries = { | ||
{ | ||
name = "sed", | ||
binary = "sed", | ||
help = "https://www.gnu.org/software/sed/manual/sed.html", | ||
}, | ||
{ | ||
name = "gg", | ||
binary = "gg", | ||
help = "https://github.com/alexpasmantier/grip-grab", | ||
}, | ||
} | ||
|
||
for _, binary in ipairs(required_binaries) do | ||
if not utils.check_binary_installed(binary.binary) then | ||
handle_error( | ||
"[pymple.nvim]: Binary " | ||
.. binary.name | ||
.. " is not installed. Please install it to use pymple.nvim.\nFor more information, see " | ||
.. binary.help | ||
) | ||
end | ||
end |