mirror of
https://github.com/nmasur/dotfiles
synced 2025-07-05 20:50:15 +00:00
partial setup of neovim for home config
This commit is contained in:
22
modules/neovim/config/bufferline.nix
Normal file
22
modules/neovim/config/bufferline.nix
Normal file
@ -0,0 +1,22 @@
|
||||
{ pkgs, ... }: {
|
||||
plugins = [
|
||||
pkgs.vimPlugins.bufferline-nvim
|
||||
pkgs.vimPlugins.vim-bbye # Better closing of buffers
|
||||
];
|
||||
setup.bufferline = {
|
||||
options = {
|
||||
diagnostics = "nvim_lsp";
|
||||
always_show_bufferline = false;
|
||||
separator_style = "slant";
|
||||
offsets = [{ filetype = "NvimTree"; }];
|
||||
};
|
||||
};
|
||||
lua = ''
|
||||
-- Move buffers
|
||||
vim.keymap.set("n", "L", ":BufferLineCycleNext<CR>", { silent = true })
|
||||
vim.keymap.set("n", "H", ":BufferLineCyclePrev<CR>", { silent = true })
|
||||
|
||||
-- Kill buffer
|
||||
vim.keymap.set("n", "<Leader>x", " :Bdelete<CR>", { silent = true })
|
||||
'';
|
||||
}
|
155
modules/neovim/config/completion.nix
Normal file
155
modules/neovim/config/completion.nix
Normal file
@ -0,0 +1,155 @@
|
||||
{ pkgs, dsl, ... }: {
|
||||
|
||||
plugins = [
|
||||
pkgs.vimPlugins.cmp-nvim-lsp
|
||||
pkgs.vimPlugins.cmp-buffer
|
||||
pkgs.vimPlugins.cmp-path
|
||||
pkgs.vimPlugins.cmp-cmdline
|
||||
pkgs.vimPlugins.cmp-nvim-lua
|
||||
pkgs.vimPlugins.luasnip
|
||||
pkgs.vimPlugins.cmp_luasnip
|
||||
pkgs.vimPlugins.cmp-rg
|
||||
pkgs.vimPlugins.friendly-snippets
|
||||
];
|
||||
|
||||
use.cmp.setup = dsl.callWith {
|
||||
|
||||
# Disable in telescope buffers
|
||||
enabled = dsl.rawLua ''
|
||||
function()
|
||||
if vim.bo.buftype == "prompt" then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
'';
|
||||
|
||||
snippet.expand = dsl.rawLua ''
|
||||
function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
end
|
||||
'';
|
||||
|
||||
mapping = {
|
||||
"['<C-n>']" = dsl.rawLua
|
||||
"require('cmp').mapping.select_next_item({ behavior = require('cmp').SelectBehavior.Insert })";
|
||||
"['<C-p>']" = dsl.rawLua
|
||||
"require('cmp').mapping.select_prev_item({ behavior = require('cmp').SelectBehavior.Insert })";
|
||||
"['<Down>']" = dsl.rawLua
|
||||
"require('cmp').mapping.select_next_item({ behavior = require('cmp').SelectBehavior.Select })";
|
||||
"['<Up>']" = dsl.rawLua
|
||||
"require('cmp').mapping.select_prev_item({ behavior = require('cmp').SelectBehavior.Select })";
|
||||
"['<C-d>']" = dsl.rawLua "require('cmp').mapping.scroll_docs(-4)";
|
||||
"['<C-f>']" = dsl.rawLua "require('cmp').mapping.scroll_docs(4)";
|
||||
"['<C-e>']" = dsl.rawLua "require('cmp').mapping.abort()";
|
||||
"['<CR>']" = dsl.rawLua
|
||||
"require('cmp').mapping.confirm({ behavior = require('cmp').ConfirmBehavior.Replace, select = true, })";
|
||||
"['<C-r>']" = dsl.rawLua
|
||||
"require('cmp').mapping.confirm({ behavior = require('cmp').ConfirmBehavior.Replace, select = true, })";
|
||||
"['<Esc>']" = dsl.rawLua ''
|
||||
function(_)
|
||||
cmp.mapping({
|
||||
i = cmp.mapping.abort(),
|
||||
c = cmp.mapping.close(),
|
||||
})
|
||||
vim.cmd("stopinsert") --- Abort and leave insert mode
|
||||
end
|
||||
'';
|
||||
"['<C-l>']" = dsl.rawLua ''
|
||||
cmp.mapping(function(_)
|
||||
if require("luasnip").expand_or_jumpable() then
|
||||
require("luasnip").expand_or_jump()
|
||||
end
|
||||
end, { "i", "s" })
|
||||
'';
|
||||
};
|
||||
|
||||
sources = [
|
||||
{ name = "nvim_lua"; }
|
||||
{ name = "nvim_lsp"; }
|
||||
{ name = "luasnip"; }
|
||||
{ name = "path"; }
|
||||
{
|
||||
name = "buffer";
|
||||
keyword_length = 3;
|
||||
max_item_count = 10;
|
||||
}
|
||||
{
|
||||
name = "rg";
|
||||
keyword_length = 6;
|
||||
max_item_count = 10;
|
||||
option = { additional_arguments = "--ignore-case"; };
|
||||
}
|
||||
];
|
||||
|
||||
formatting = {
|
||||
fields = [ "kind" "abbr" "menu" ];
|
||||
format = dsl.rawLua ''
|
||||
function(entry, vim_item)
|
||||
local kind_icons = {
|
||||
Text = "",
|
||||
Method = "m",
|
||||
Function = "",
|
||||
Constructor = "",
|
||||
Field = "",
|
||||
Variable = "",
|
||||
Class = "",
|
||||
Interface = "",
|
||||
Module = "",
|
||||
Property = "",
|
||||
Unit = "",
|
||||
Value = "",
|
||||
Enum = "",
|
||||
Keyword = "",
|
||||
Snippet = "",
|
||||
Color = "",
|
||||
File = "",
|
||||
Reference = "",
|
||||
Folder = "",
|
||||
EnumMember = "",
|
||||
Constant = "",
|
||||
Struct = "",
|
||||
Event = "",
|
||||
Operator = "",
|
||||
TypeParameter = "",
|
||||
}
|
||||
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
|
||||
vim_item.menu = ({
|
||||
luasnip = "[Snippet]",
|
||||
buffer = "[Buffer]",
|
||||
path = "[Path]",
|
||||
rg = "[Grep]",
|
||||
nvim_lsp = "[LSP]",
|
||||
nvim_lua = "[Lua]",
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end
|
||||
'';
|
||||
};
|
||||
|
||||
experimental = {
|
||||
native_menu = false; # Use cmp menu instead of Vim menu
|
||||
ghost_text = true; # Show preview auto-completion
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
lua = ''
|
||||
-- Use buffer source for `/`
|
||||
require('cmp').setup.cmdline("/", {
|
||||
sources = {
|
||||
{ name = "buffer", keyword_length = 5 },
|
||||
},
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':'
|
||||
require('cmp').setup.cmdline(":", {
|
||||
sources = require('cmp').config.sources({
|
||||
{ name = "path" },
|
||||
}, {
|
||||
{ name = "cmdline" },
|
||||
}),
|
||||
})
|
||||
'';
|
||||
|
||||
}
|
35
modules/neovim/config/gitsigns.lua
Normal file
35
modules/neovim/config/gitsigns.lua
Normal file
@ -0,0 +1,35 @@
|
||||
vim.keymap.set("", "<Space>", "<Nop>", { silent = true })
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = " "
|
||||
|
||||
local gitsigns = require("gitsigns")
|
||||
vim.keymap.set("n", "<Leader>gB", gitsigns.blame_line)
|
||||
vim.keymap.set("n", "<Leader>gp", gitsigns.preview_hunk)
|
||||
vim.keymap.set("v", "<Leader>gp", gitsigns.preview_hunk)
|
||||
vim.keymap.set("n", "<Leader>gd", gitsigns.diffthis)
|
||||
vim.keymap.set("v", "<Leader>gd", gitsigns.diffthis)
|
||||
vim.keymap.set("n", "<Leader>rgf", gitsigns.reset_buffer)
|
||||
vim.keymap.set("v", "<Leader>hs", gitsigns.stage_hunk)
|
||||
vim.keymap.set("v", "<Leader>hr", gitsigns.reset_hunk)
|
||||
vim.keymap.set("v", "<Leader>hr", gitsigns.reset_hunk)
|
||||
|
||||
-- Navigation
|
||||
vim.keymap.set("n", "]g", function()
|
||||
if vim.wo.diff then
|
||||
return "]g"
|
||||
end
|
||||
vim.schedule(function()
|
||||
gitsigns.next_hunk()
|
||||
end)
|
||||
return "<Ignore>"
|
||||
end, { expr = true })
|
||||
|
||||
vim.keymap.set("n", "[g", function()
|
||||
if vim.wo.diff then
|
||||
return "[g"
|
||||
end
|
||||
vim.schedule(function()
|
||||
gitsigns.prev_hunk()
|
||||
end)
|
||||
return "<Ignore>"
|
||||
end, { expr = true })
|
5
modules/neovim/config/gitsigns.nix
Normal file
5
modules/neovim/config/gitsigns.nix
Normal file
@ -0,0 +1,5 @@
|
||||
{ pkgs, ... }: {
|
||||
plugins = [ pkgs.vimPlugins.gitsigns-nvim ];
|
||||
setup.gitsigns = { };
|
||||
lua = builtins.readFile ./gitsigns.lua;
|
||||
}
|
10
modules/neovim/config/lsp.lua
Normal file
10
modules/neovim/config/lsp.lua
Normal file
@ -0,0 +1,10 @@
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition)
|
||||
vim.keymap.set("n", "gT", vim.lsp.buf.type_definition)
|
||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation)
|
||||
vim.keymap.set("n", "gh", vim.lsp.buf.hover)
|
||||
-- vim.keymap.set("n", "gr", telescope.lsp_references)
|
||||
vim.keymap.set("n", "<Leader>R", vim.lsp.buf.rename)
|
||||
vim.keymap.set("n", "]e", vim.diagnostic.goto_next)
|
||||
vim.keymap.set("n", "[e", vim.diagnostic.goto_prev)
|
||||
vim.keymap.set("n", "<Leader>de", vim.diagnostic.open_float)
|
||||
vim.keymap.set("n", "<Leader>E", vim.lsp.buf.code_action)
|
63
modules/neovim/config/lsp.nix
Normal file
63
modules/neovim/config/lsp.nix
Normal file
@ -0,0 +1,63 @@
|
||||
{ pkgs, dsl, ... }: {
|
||||
|
||||
plugins = [
|
||||
pkgs.vimPlugins.nvim-lspconfig
|
||||
pkgs.vimPlugins.lsp-colors-nvim
|
||||
pkgs.vimPlugins.null-ls-nvim
|
||||
];
|
||||
|
||||
use.lspconfig.sumneko_lua.setup = dsl.callWith {
|
||||
settings = { Lua = { diagnostics = { globals = [ "vim" "hs" ]; }; }; };
|
||||
capabilities = dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()";
|
||||
cmd = [ "${pkgs.sumneko-lua-language-server}/bin/lua-language-server" ];
|
||||
};
|
||||
|
||||
use.lspconfig.nil_ls.setup = dsl.callWith {
|
||||
cmd = [ "${pkgs.nil}/bin/nil" ];
|
||||
capabilities = dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()";
|
||||
};
|
||||
|
||||
use.lspconfig.pyright.setup = dsl.callWith {
|
||||
cmd = [ "${pkgs.pyright}/bin/pyright-langserver" "--stdio" ];
|
||||
};
|
||||
|
||||
use.lspconfig.terraformls.setup =
|
||||
dsl.callWith { cmd = [ "${pkgs.terraform-ls}/bin/terraform-lsp" ]; };
|
||||
|
||||
vim.api.nvim_create_augroup = dsl.callWith [ "LspFormatting" { } ];
|
||||
|
||||
lua = ''
|
||||
${builtins.readFile ./lsp.lua}
|
||||
|
||||
require("null-ls").setup({
|
||||
sources = {
|
||||
require("null-ls").builtins.formatting.stylua.with({ command = "${pkgs.stylua}/bin/stylua" }),
|
||||
require("null-ls").builtins.formatting.black.with({ command = "${pkgs.black}/bin/black" }),
|
||||
require("null-ls").builtins.diagnostics.flake8.with({ command = "${pkgs.python310Packages.flake8}/bin/flake8" }),
|
||||
require("null-ls").builtins.formatting.fish_indent.with({ command = "${pkgs.fish}/bin/fish_indent" }),
|
||||
require("null-ls").builtins.formatting.nixfmt.with({ command = "${pkgs.nixfmt}/bin/nixfmt" }),
|
||||
require("null-ls").builtins.formatting.rustfmt.with({ command = "${pkgs.rustfmt}/bin/rustfmt" }),
|
||||
require("null-ls").builtins.diagnostics.shellcheck.with({ command = "${pkgs.shellcheck}/bin/shellcheck" }),
|
||||
require("null-ls").builtins.formatting.shfmt.with({
|
||||
command = "${pkgs.shfmt}/bin/shfmt",
|
||||
extra_args = { "-i", "4", "-ci" },
|
||||
}),
|
||||
require("null-ls").builtins.formatting.terraform_fmt.with({ command = "${pkgs.terraform}/bin/terraform" }),
|
||||
},
|
||||
|
||||
on_attach = function(client, bufnr)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ bufnr = bufnr })
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
'';
|
||||
|
||||
}
|
70
modules/neovim/config/misc.nix
Normal file
70
modules/neovim/config/misc.nix
Normal file
@ -0,0 +1,70 @@
|
||||
{ pkgs, dsl, lib, ... }: {
|
||||
plugins = [
|
||||
pkgs.vimPlugins.vim-surround # Keybinds for surround characters
|
||||
pkgs.vimPlugins.vim-eunuch # File manipulation commands
|
||||
pkgs.vimPlugins.vim-fugitive # Git commands
|
||||
pkgs.vimPlugins.vim-repeat # Better repeat using .
|
||||
pkgs.vimPlugins.comment-nvim # Smart comment commands
|
||||
pkgs.vimPlugins.impatient-nvim # Faster load times
|
||||
pkgs.vimPlugins.glow-nvim # Markdown preview popup
|
||||
pkgs.vimPlugins.nvim-colorizer-lua # Hex color previews
|
||||
];
|
||||
|
||||
setup.Comment = { };
|
||||
setup.colorizer = { };
|
||||
|
||||
vim.o = {
|
||||
termguicolors = true; # Set to truecolor
|
||||
hidden = true; # Don't unload buffers when leaving them
|
||||
list = true; # Reveal whitespace with dashes
|
||||
expandtab = true; # Tabs into spaces
|
||||
shiftwidth = 4; # Amount to shift with > key
|
||||
softtabstop = 4; # Amount to shift with <TAB> key
|
||||
ignorecase = true; # Ignore case when searching
|
||||
smartcase = true; # Check case when using capitals in search
|
||||
infercase = true; # Don't match cases when completing suggestions
|
||||
incsearch = true; # Search while typing
|
||||
visualbell = true; # No sounds
|
||||
scrolljump = 1; # Number of lines to scroll
|
||||
scrolloff = 3; # Margin of lines to see while scrolling
|
||||
splitright = true; # Vertical splits on the right side
|
||||
splitbelow = true; # Horizontal splits on the bottom side
|
||||
pastetoggle = "<F3>"; # Use F3 to enter raw paste mode
|
||||
clipboard = "unnamedplus"; # Uses system clipboard for yanking
|
||||
updatetime = 300; # Faster diagnostics
|
||||
mouse = "nv"; # Mouse interaction / scrolling
|
||||
inccommand = "split"; # Live preview search and replace
|
||||
};
|
||||
|
||||
vim.wo = {
|
||||
number = true; # Show line numbers
|
||||
relativenumber = true; # Relative numbers instead of absolute
|
||||
};
|
||||
|
||||
# Better backup, swap and undo storage
|
||||
vim.o.backup = true; # Easier to recover and more secure
|
||||
vim.bo.swapfile = false; # Instead of swaps, create backups
|
||||
vim.bo.undofile = true; # Keeps undos after quit
|
||||
vim.o.backupdir = dsl.rawLua ''vim.fn.stdpath("cache") .. "/backup"'';
|
||||
|
||||
# Required for nvim-cmp completion
|
||||
vim.opt.completeopt = [ "menu" "menuone" "noselect" ];
|
||||
|
||||
lua = lib.mkBefore ''
|
||||
require("impatient")
|
||||
${builtins.readFile ../lua/keybinds.lua};
|
||||
${builtins.readFile ../lua/settings.lua};
|
||||
'';
|
||||
|
||||
vimscript = ''
|
||||
" Remember last position when reopening file
|
||||
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
|
||||
|
||||
" LaTeX options
|
||||
au FileType tex inoremap ;bf \textbf{}<Esc>i
|
||||
au BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw!
|
||||
|
||||
" Flash highlight when yanking
|
||||
au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 }
|
||||
'';
|
||||
}
|
9
modules/neovim/config/statusline.nix
Normal file
9
modules/neovim/config/statusline.nix
Normal file
@ -0,0 +1,9 @@
|
||||
{ pkgs, ... }: {
|
||||
plugins = [ pkgs.vimPlugins.lualine-nvim ];
|
||||
setup.lualine = {
|
||||
options = {
|
||||
theme = "gruvbox";
|
||||
icons_enabled = true;
|
||||
};
|
||||
};
|
||||
}
|
52
modules/neovim/config/syntax.nix
Normal file
52
modules/neovim/config/syntax.nix
Normal file
@ -0,0 +1,52 @@
|
||||
{ pkgs, ... }: {
|
||||
|
||||
plugins = [
|
||||
(pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins:
|
||||
with pkgs.tree-sitter-grammars; [
|
||||
tree-sitter-hcl
|
||||
tree-sitter-python
|
||||
tree-sitter-lua
|
||||
tree-sitter-nix
|
||||
tree-sitter-fish
|
||||
tree-sitter-toml
|
||||
tree-sitter-yaml
|
||||
tree-sitter-json
|
||||
]))
|
||||
pkgs.vimPlugins.vim-matchup # Better % jumping in languages
|
||||
pkgs.vimPlugins.nginx-vim
|
||||
pkgs.vimPlugins.vim-helm
|
||||
pkgs.vimPlugins.vim-puppet
|
||||
];
|
||||
|
||||
setup."nvim-treesitter.configs" = {
|
||||
highlight = { enable = true; };
|
||||
indent = { enable = true; };
|
||||
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true;
|
||||
lookahead = true; # Jump forward automatically
|
||||
|
||||
keymaps = {
|
||||
"['af']" = "@function.outer";
|
||||
"['if']" = "@function.inner";
|
||||
"['ac']" = "@class.outer";
|
||||
"['ic']" = "@class.inner";
|
||||
"['al']" = "@loop.outer";
|
||||
"['il']" = "@loop.inner";
|
||||
"['aa']" = "@call.outer";
|
||||
"['ia']" = "@call.inner";
|
||||
"['ar']" = "@parameter.outer";
|
||||
"['ir']" = "@parameter.inner";
|
||||
"['aC']" = "@comment.outer";
|
||||
"['iC']" = "@comment.outer";
|
||||
"['a/']" = "@comment.outer";
|
||||
"['i/']" = "@comment.outer";
|
||||
"['a;']" = "@statement.outer";
|
||||
"['i;']" = "@statement.outer";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
}
|
69
modules/neovim/config/telescope.lua
Normal file
69
modules/neovim/config/telescope.lua
Normal file
@ -0,0 +1,69 @@
|
||||
local telescope = require("telescope.builtin")
|
||||
vim.keymap.set("n", "<Leader>k", telescope.keymaps)
|
||||
vim.keymap.set("n", "<Leader>/", telescope.live_grep)
|
||||
vim.keymap.set("n", "<Leader>ff", telescope.find_files)
|
||||
vim.keymap.set("n", "<Leader>fp", telescope.git_files)
|
||||
vim.keymap.set("n", "<Leader>fw", telescope.grep_string)
|
||||
vim.keymap.set("n", "<Leader>b", telescope.buffers)
|
||||
vim.keymap.set("n", "<Leader>hh", telescope.help_tags)
|
||||
vim.keymap.set("n", "<Leader>fr", telescope.oldfiles)
|
||||
vim.keymap.set("n", "<Leader>cc", telescope.commands)
|
||||
vim.keymap.set("n", "<Leader>gc", telescope.git_commits)
|
||||
vim.keymap.set("n", "<Leader>gf", telescope.git_bcommits)
|
||||
vim.keymap.set("n", "<Leader>gb", telescope.git_branches)
|
||||
vim.keymap.set("n", "<Leader>gs", telescope.git_status)
|
||||
vim.keymap.set("n", "<Leader>s", telescope.current_buffer_fuzzy_find)
|
||||
|
||||
vim.keymap.set("n", "<Leader>N", function()
|
||||
local opts = {
|
||||
prompt_title = "Search Notes",
|
||||
cwd = "$NOTES_PATH",
|
||||
}
|
||||
telescope.live_grep(opts)
|
||||
end)
|
||||
|
||||
vim.keymap.set("n", "<Leader>fN", function()
|
||||
local opts = {
|
||||
prompt_title = "Find Notes",
|
||||
cwd = "$NOTES_PATH",
|
||||
}
|
||||
telescope.find_files(opts)
|
||||
end)
|
||||
|
||||
vim.keymap.set("n", "<Leader>cr", function()
|
||||
local opts = require("telescope.themes").get_ivy({
|
||||
layout_config = {
|
||||
bottom_pane = {
|
||||
height = 15,
|
||||
},
|
||||
},
|
||||
})
|
||||
telescope.command_history(opts)
|
||||
end)
|
||||
|
||||
-- Zoxide
|
||||
vim.keymap.set("n", "<Leader>fz", require("telescope").extensions.zoxide.list)
|
||||
|
||||
-- Project
|
||||
require("telescope").load_extension("project")
|
||||
vim.keymap.set("n", "<C-p>", function()
|
||||
local opts = require("telescope.themes").get_ivy({
|
||||
layout_config = {
|
||||
bottom_pane = {
|
||||
height = 10,
|
||||
},
|
||||
},
|
||||
})
|
||||
require("telescope").extensions.project.project(opts)
|
||||
end)
|
||||
|
||||
-- File browser
|
||||
require("telescope").load_extension("file_browser")
|
||||
vim.keymap.set("n", "<Leader>fa", require("telescope").extensions.file_browser.file_browser)
|
||||
vim.keymap.set("n", "<Leader>fD", function()
|
||||
local opts = {
|
||||
prompt_title = "Find Downloads",
|
||||
cwd = "~/downloads",
|
||||
}
|
||||
require("telescope").extensions.file_browser.file_browser(opts)
|
||||
end)
|
34
modules/neovim/config/telescope.nix
Normal file
34
modules/neovim/config/telescope.nix
Normal file
@ -0,0 +1,34 @@
|
||||
{ pkgs, dsl, ... }: {
|
||||
|
||||
plugins = [
|
||||
pkgs.vimPlugins.telescope-nvim
|
||||
pkgs.vimPlugins.telescope-project-nvim
|
||||
pkgs.vimPlugins.telescope-fzy-native-nvim
|
||||
pkgs.vimPlugins.telescope-file-browser-nvim
|
||||
pkgs.vimPlugins.telescope-zoxide
|
||||
];
|
||||
|
||||
setup.telescope = {
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
"['<esc>']" = dsl.rawLua "require('telescope.actions').close";
|
||||
"['<C-h>']" = "which_key";
|
||||
};
|
||||
};
|
||||
};
|
||||
pickers = {
|
||||
find_files = { theme = "ivy"; };
|
||||
oldfiles = { theme = "ivy"; };
|
||||
buffers = { theme = "dropdown"; };
|
||||
};
|
||||
extensions = {
|
||||
fzy_native = { };
|
||||
zoxide = { };
|
||||
project = { base_dirs = [ "~/dev" ]; };
|
||||
};
|
||||
};
|
||||
|
||||
lua = builtins.readFile ./telescope.lua;
|
||||
|
||||
}
|
40
modules/neovim/config/toggleterm.lua
Normal file
40
modules/neovim/config/toggleterm.lua
Normal file
@ -0,0 +1,40 @@
|
||||
vim.keymap.set("t", "<A-CR>", "<C-\\><C-n>") --- Exit terminal mode
|
||||
|
||||
-- Only set these keymaps for toggleterm
|
||||
vim.api.nvim_create_autocmd("TermOpen", {
|
||||
pattern = "term://*toggleterm#*",
|
||||
callback = function()
|
||||
-- vim.keymap.set("t", "<Esc>", "<C-\\><C-n>") --- Exit terminal mode
|
||||
vim.keymap.set("t", "<C-h>", "<C-\\><C-n><C-w>h")
|
||||
vim.keymap.set("t", "<C-j>", "<C-\\><C-n><C-w>j")
|
||||
vim.keymap.set("t", "<C-k>", "<C-\\><C-n><C-w>k")
|
||||
vim.keymap.set("t", "<C-l>", "<C-\\><C-n><C-w>l")
|
||||
end,
|
||||
})
|
||||
|
||||
local terminal = require("toggleterm.terminal").Terminal
|
||||
|
||||
local basicterminal = terminal:new()
|
||||
function TERM_TOGGLE()
|
||||
basicterminal:toggle()
|
||||
end
|
||||
|
||||
local nixpkgs = terminal:new({ cmd = "nix repl '<nixpkgs>'" })
|
||||
function NIXPKGS_TOGGLE()
|
||||
nixpkgs:toggle()
|
||||
end
|
||||
|
||||
local gitwatch = terminal:new({ cmd = "fish --interactive --init-command 'gh run watch'" })
|
||||
function GITWATCH_TOGGLE()
|
||||
gitwatch:toggle()
|
||||
end
|
||||
|
||||
local k9s = terminal:new({ cmd = "k9s" })
|
||||
function K9S_TOGGLE()
|
||||
k9s:toggle()
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<Leader>t", TERM_TOGGLE)
|
||||
vim.keymap.set("n", "<Leader>P", NIXPKGS_TOGGLE)
|
||||
vim.keymap.set("n", "<Leader>gw", GITWATCH_TOGGLE)
|
||||
vim.keymap.set("n", "<Leader>9", K9S_TOGGLE)
|
13
modules/neovim/config/toggleterm.nix
Normal file
13
modules/neovim/config/toggleterm.nix
Normal file
@ -0,0 +1,13 @@
|
||||
{ pkgs, dsl, ... }: {
|
||||
|
||||
plugins = [ pkgs.vimPlugins.toggleterm-nvim ];
|
||||
|
||||
use.toggleterm.setup = dsl.callWith {
|
||||
open_mapping = dsl.rawLua "[[<c-\\>]]";
|
||||
hide_numbers = true;
|
||||
direction = "float";
|
||||
};
|
||||
|
||||
lua = builtins.readFile ./toggleterm.lua;
|
||||
|
||||
}
|
77
modules/neovim/config/tree.nix
Normal file
77
modules/neovim/config/tree.nix
Normal file
@ -0,0 +1,77 @@
|
||||
{ pkgs, dsl, ... }: {
|
||||
|
||||
plugins = [ pkgs.vimPlugins.nvim-tree-lua pkgs.vimPlugins.nvim-web-devicons ];
|
||||
|
||||
# Disable netrw eagerly
|
||||
# https://github.com/kyazdani42/nvim-tree.lua/commit/fb8735e96cecf004fbefb086ce85371d003c5129
|
||||
vim.g = {
|
||||
loaded = 1;
|
||||
loaded_netrwPlugin = 1;
|
||||
};
|
||||
|
||||
setup.nvim-tree = {
|
||||
disable_netrw = true;
|
||||
hijack_netrw = true;
|
||||
update_focused_file = {
|
||||
enable = true;
|
||||
update_cwd = true;
|
||||
ignore_list = { };
|
||||
};
|
||||
diagnostics = {
|
||||
enable = true;
|
||||
icons = {
|
||||
hint = "";
|
||||
info = "";
|
||||
warning = "";
|
||||
error = "";
|
||||
};
|
||||
};
|
||||
renderer = {
|
||||
icons = {
|
||||
glyphs = {
|
||||
git = {
|
||||
unstaged = "~";
|
||||
staged = "+";
|
||||
unmerged = "";
|
||||
renamed = "➜";
|
||||
deleted = "";
|
||||
untracked = "?";
|
||||
ignored = "◌";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
view = {
|
||||
width = 30;
|
||||
hide_root_folder = false;
|
||||
side = "left";
|
||||
mappings = {
|
||||
custom_only = false;
|
||||
list = [
|
||||
{
|
||||
key = [ "l" "<CR>" "o" ];
|
||||
cb = dsl.rawLua
|
||||
"require('nvim-tree.config').nvim_tree_callback('edit')";
|
||||
}
|
||||
{
|
||||
key = "h";
|
||||
cb = dsl.rawLua
|
||||
"require('nvim-tree.config').nvim_tree_callback('close_node')";
|
||||
}
|
||||
{
|
||||
key = "v";
|
||||
cb = dsl.rawLua
|
||||
"require('nvim-tree.config').nvim_tree_callback('vsplit')";
|
||||
}
|
||||
];
|
||||
};
|
||||
number = false;
|
||||
relativenumber = false;
|
||||
};
|
||||
};
|
||||
|
||||
lua = ''
|
||||
vim.keymap.set("n", "<Leader>e", ":NvimTreeFindFileToggle<CR>", { silent = true })
|
||||
'';
|
||||
|
||||
}
|
Reference in New Issue
Block a user