Skip to content

Commit

Permalink
Merge pull request #59 from redyf/dev
Browse files Browse the repository at this point in the history
Dev Experience Improvements
  • Loading branch information
redyf authored Feb 12, 2024
2 parents c166f26 + d300813 commit 13a7c7f
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 46 deletions.
76 changes: 69 additions & 7 deletions config/keymaps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,27 @@
action = "mzJ`z";
options = {
silent = true;
desc = "Allow cursor to stay in the same place after appending to current line ";
desc = "Allow cursor to stay in the same place after appeding to current line";
};
}

{
mode = "v";
key = "<";
action = "<gv";
options = {
silent = true;
desc = "Indent while remaining in visual mode.";
};
}

{
mode = "v";
key = ">";
action = ">gv";
options = {
silent = true;
desc = "Indent while remaining in visual mode.";
};
}

Expand All @@ -346,7 +366,7 @@
action = "<C-d>zz";
options = {
silent = true;
desc = "Allow C-d and C-u to keep the cursor in the middle";
desc = "Allow <C-d> and <C-u> to keep the cursor in the middle";
};
}

Expand All @@ -359,6 +379,31 @@
};
}

# Remap for dealing with word wrap and adding jumps to the jumplist.
{
mode = "n";
key = "j";
action.__raw = "
[[(v:count > 1 ? 'm`' . v:count : 'g') . 'j']]
";
options = {
expr = true;
desc = "Remap for dealing with word wrap and adding jumps to the jumplist.";
};
}

{
mode = "n";
key = "k";
action.__raw = "
[[(v:count > 1 ? 'm`' . v:count : 'g') . 'k']]
";
options = {
expr = true;
desc = "Remap for dealing with word wrap and adding jumps to the jumplist.";
};
}

{
mode = "n";
key = "n";
Expand Down Expand Up @@ -433,27 +478,44 @@
}
];
extraConfigLua = ''
local notify = require("notify")
local function show_notification(message, level)
notify(message, level, { title = "conform.nvim" })
end
function ToggleLineNumber()
if vim.wo.number then
vim.wo.number = false
show_notification("Line numbers disabled", "info")
else
vim.wo.number = true
vim.wo.relativenumber = false
show_notification("Line numbers enabled", "info")
end
end
function ToggleRelativeLineNumber()
if vim.wo.relativenumber then
vim.wo.relativenumber = false
show_notification("Relative line numbers disabled", "info")
else
vim.wo.relativenumber = true
vim.wo.number = false
end
end
show_notification("Relative line numbers enabled", "info")
end
end
function ToggleWrap()
vim.wo.wrap = not vim.wo.wrap
end
function ToggleWrap()
if vim.wo.wrap then
vim.wo.wrap = false
show_notification("Wrap disabled", "info")
else
vim.wo.wrap = true
vim.wo.number = false
show_notification("Wrap enabled", "info")
end
end
if vim.lsp.inlay_hint then
vim.keymap.set(
Expand Down
52 changes: 30 additions & 22 deletions config/lsp/conform.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,36 @@
};
};

keymaps = [
{
mode = "n";
key = "<leader>uf";
action = ":FormatToggle<CR>";
options = {
desc = "Toggle Format";
silent = true;
};
}
{
mode = [ "n" "v" ];
key = "<leader>cf";
action = "<cmd>lua require('conform').format()<cr>";
options = {
silent = true;
desc = "Format Buffer";
};
}
{
mode = "v";
key = "<leader>cF";
action = "<cmd>lua vim.lsp.buf.format()<cr>";
options = {
silent = true;
desc = "Format Lines";
};
}
];

extraConfigLua = ''
local conform = require("conform")
local notify = require("notify")
Expand Down Expand Up @@ -57,27 +87,5 @@
desc = "Toggle autoformat-on-save",
bang = true,
})
'';

keymaps = [
{
mode = "n";
key = "<leader>uf";
action = ":FormatToggle<CR>";
options = {
desc = "Toggle Format";
silent = true;
};
}
{
mode = [ "n" "v" ];
key = "<leader>cf";
action = "<cmd>lua require('conform').format()<cr>";
options = {
silent = true;
desc = "Format";
};
}
];
}
6 changes: 4 additions & 2 deletions config/sets.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
number = true;
relativenumber = true;

# Set tabs to 2 spaces
# Set tabs to 2 spaces
tabstop = 2;
softtabstop = 2;
showtabline = 2;
Expand Down Expand Up @@ -53,7 +53,7 @@
backup = false;
undofile = true;

# Enable 24-bit colors
# Enable 24-bit colors
termguicolors = true;

# Enable the sign column to prevent the screen from jumping
Expand Down Expand Up @@ -106,6 +106,8 @@
# Maximum number of items to show in the popup menu (0 means "use available screen space")
pumheight = 0;

# Use conform-nvim for gq formatting. ('formatexpr' is set to vim.lsp.formatexpr(), so you can format lines via gq if the language server supports it)
formatexpr = "v:lua.require'conform'.formatexpr()";
};

extraConfigLua = ''
Expand Down
30 changes: 15 additions & 15 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 13a7c7f

Please sign in to comment.