Skip to content

Commit

Permalink
perf(neovim): outsource keybindings to lazy.nvim, also rename plugin …
Browse files Browse the repository at this point in the history
…config files
  • Loading branch information
Botond Kalocsai committed Apr 17, 2024
1 parent e88b9c4 commit 184f9b3
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 105 deletions.
34 changes: 5 additions & 29 deletions home/dot_config/nvim/lua/config/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,8 @@
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here

if vim.g.vscode then
-- vscode-nvim settings
else
-- iron also has a list of commands, see :h iron-commands for all available commands
vim.keymap.set("n", "<space>rs", "<cmd>IronRepl<cr>")
vim.keymap.set("n", "<space>rr", "<cmd>IronRestart<cr>")
vim.keymap.set("n", "<space>rF", "<cmd>IronFocus<cr>")
vim.keymap.set("n", "<space>rh", "<cmd>IronHide<cr>")

local telescope = require("telescope")

-- Zoxide
telescope.load_extension("zoxide")
vim.keymap.set(
"n",
"<leader>fd",
require("telescope").extensions.zoxide.list,
{ desc = "Change directory (cwd)" }
)

-- Chezmoi
telescope.load_extension("chezmoi")
vim.keymap.set(
"n",
"<leader>fz",
telescope.extensions.chezmoi.find_files,
{ desc = "Find Chezmoi Source File" }
)
end
-- if vim.g.vscode then
-- -- vscode-nvim settings
-- else
-- -- Ordinary nvim settings
-- end
17 changes: 14 additions & 3 deletions home/dot_config/nvim/lua/plugins/chezmoi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,20 @@ return {
"xvzc/chezmoi.nvim", -- For chezmoi-managed file editing, applying
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
require("chezmoi").setup({
-- your configurations
})
local telescope = require("telescope")
-- require("chezmoi").setup({
-- -- your configurations
-- })
telescope.load_extension("chezmoi")
end,
keys = {
{
"<leader>fz",
function()
require("telescope").extensions.chezmoi.find_files()
end,
desc = "Find Chezmoi Source File",
},
},
},
}
File renamed without changes.
66 changes: 0 additions & 66 deletions home/dot_config/nvim/lua/plugins/iron-repl.lua

This file was deleted.

85 changes: 85 additions & 0 deletions home/dot_config/nvim/lua/plugins/repl.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
return {
{ -- Adding group name for REPL
"folke/which-key.nvim",
opts = {
defaults = {
["<leader>r"] = { name = "+repl" },
["<leader>rm"] = { name = "+mark" },
},
},
},
{ -- https://dev.to/rnrbarbosa/how-to-run-python-on-neovim-like-jupyter-3ln0
"Vigemus/iron.nvim",
config = function(plugins, opts)
local iron = require("iron")
local view = require("iron.view")
local fts = require("iron.fts")

table.insert(fts.python.ipython.command, "--no-confirm-exit")
table.insert(fts.python.ipython.command, "--pylab=qt")
if vim.fn.executable("pwsh") then
fts.ps1.ps1.command[1] = "pwsh"
end
iron.core.setup({
config = {
-- Whether a repl should be discarded or not
scratch_repl = false,
-- Your repl definitions come here
repl_definition = {
python = fts.python.ipython,
ps1 = fts.ps1.ps1,
sh = fts.sh.sh,
},
-- How the repl window will be displayed
-- See below for more information
repl_open_cmd = view.right(85),
},
-- Iron doesn't set keymaps by default anymore.
-- You can set them here or manually add keymaps to the functions in iron.core
keymaps = {
send_motion = "<leader>rc",
visual_send = "<leader>rc",
send_file = "<leader>rf",
send_line = "<leader>rl",
send_until_cursor = "<leader>ru",
send_mark = "<leader>rm",
mark_motion = "<leader>rmc",
mark_visual = "<leader>rmc",
remove_mark = "<leader>rmd",
cr = "<leader>r<cr>",
interrupt = "<leader>r<space>",
exit = "<leader>rq",
clear = "<leader>rx",
},
-- If the highlight is on, you can change how it looks
-- For the available options, check nvim_set_hl
highlight = {
italic = true,
},
ignore_blank_lines = true, -- ignore blank lines when sending visual select lines
})
end,
keys = {
{
"<leader>rs",
"<cmd>IronRepl<cr>",
desc = "Open REPL",
},
{
"<leader>rr",
"<cmd>IronRestart<cr>",
desc = "Restart REPL",
},
{
"<leader>rF",
"<cmd>IronFocus<cr>",
desc = "Focus on REPL",
},
{
"<leader>rh",
"<cmd>IronHide<cr>",
desc = "Hide REPL",
},
},
},
}
32 changes: 25 additions & 7 deletions home/dot_config/nvim/lua/plugins/zoxide.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,31 @@ return {
"nvim-telescope/telescope.nvim",
},
config = function()
local telescope = require("telescope")
-- local z_utils = require("telescope._extensions.zoxide.utils")
require("telescope").setup({
extensions = {
zoxide = {
-- your configurations
},
},
})
-- telescope.setup({
-- extensions = {
-- zoxide = {
-- -- your configurations
-- },
-- },
-- })
telescope.load_extension("zoxide")
end,
keys = {
{
"<leader>fd",
function()
require("telescope").extensions.zoxide.list()
end,
desc = "Change directory (cwd)",
},
{
"<leader>d",
function()
require("telescope").extensions.zoxide.list()
end,
desc = "Change directory (cwd)",
},
},
}

0 comments on commit 184f9b3

Please sign in to comment.