1
0
Fork 0

feat: Move neovim config to options

This commit is contained in:
lwad 2024-03-14 23:28:39 +00:00
parent 45f64c7924
commit 7fd88eb1c7
15 changed files with 511 additions and 397 deletions

View File

@ -1,391 +0,0 @@
{ pkgs, ... }:
{
environment = {
systemPackages = with pkgs;
[ # Language servers.
erlang-ls
libclang
nil
nodePackages.bash-language-server
nodePackages.typescript-language-server
python310Packages.jedi-language-server
ruff-lsp
rust-analyzer
] ++ [ # Formatters.
beautysh
libclang
nixfmt
nodePackages.prettier
rustfmt
yapf
];
variables.PATH = "${pkgs.clang-tools}/bin:$PATH";
};
programs.neovim = {
configure = {
customRC = let
visual = ''
vim.opt.signcolumn = "no"
vim.opt.number = true
vim.opt.relativenumber = true
vim.api.nvim_create_autocmd({"TermOpen"}, {
pattern = {"*"},
command = "setlocal nonumber norelativenumber",
})
vim.keymap.set("n", "<leader>z", ":ZenMode<enter>", {})
vim.opt.ignorecase = false
vim.opt.hlsearch = false
vim.opt.incsearch = true
vim.opt.scrolloff = 2
vim.opt.wrap = false
vim.opt.pumheight = 10 -- Popup menu height.
vim.opt.showmode = false -- Mode indicator.
vim.opt.shortmess = "acFIoOsW"
local colors = {
background = nil,
white = "#FFFFFF",
red = "#FF0000",
yellow = "#FFFF00",
black = "#000000",
lightgrey = "#888888",
blue = "#0000FF"
}
require("lualine").setup {
options = {
icons_enabled = true,
theme = {
normal = {
a = { bg = colors.white, fg = colors.black },
b = { bg = colors.lightgrey, fg = colors.white },
c = { bg = colors.bg, fg = colors.white },
y = { bg = colors.lightgrey, fg = colors.white },
z = { bg = colors.white, fg = colors.black }
},
command = {
a = { bg = colors.blue, fg = colors.black },
b = { bg = colors.lightgrey, fg = colors.white },
c = { bg = colors.bg, fg = colors.white },
y = { bg = colors.lightgrey, fg = colors.white },
z = { bg = colors.white, fg = colors.black }
},
insert = {
a = { bg = colors.red, fg = colors.white },
b = { bg = colors.lightgrey, fg = colors.white },
c = { bg = colors.bg, fg = colors.white },
y = { bg = colors.lightgrey, fg = colors.white },
z = { bg = colors.white, fg = colors.black }
},
visual = {
a = { bg = colors.yellow, fg = colors.black },
b = { bg = colors.lightgrey, fg = colors.white },
c = { bg = colors.bg, fg = colors.white },
y = { bg = colors.lightgrey, fg = colors.white },
z = { bg = colors.white, fg = colors.black }
},
replace = {
a = { bg = colors.black, fg = colors.white },
b = { bg = colors.lightgrey, fg = colors.white },
c = { bg = colors.bg, fg = colors.white },
y = { bg = colors.lightgrey, fg = colors.white },
z = { bg = colors.white, fg = colors.black }
}
},
component_separators = { left = "", right = ""},
section_separators = { left = "", right = ""},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
}
},
sections = {
lualine_a = {"mode"},
lualine_b = {"branch", "diff"},
lualine_c = {"diagnostics"},
lualine_x = {},
lualine_y = {"progress"},
lualine_z = {"filetype", "filename"}
},
inactive_sections = {
lualine_a = {},
lualine_b = {"branch", "diff"},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {"filetype", "filename"}
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {}
}
vim.o.background = 'dark'
if vim.fn.exists('syntax_on') then
vim.cmd('syntax reset')
end
vim.g.colors_name = 'translucent'
vim.api.nvim_set_hl(0, "FloatBorder", { fg = colors.white, bg = nil })
vim.api.nvim_set_hl(0, "PMenu", { ctermfg = "white", ctermbg = 242 })
vim.api.nvim_set_hl(0, "PMenuSbar", { ctermbg = 242 })
vim.api.nvim_set_hl(0, "PMenuSel", { ctermfg = 242, ctermbg = "white" })
vim.api.nvim_set_hl(0, "NormalFloat", { ctermfg = "white", ctermbg = nil })
vim.api.nvim_set_hl(0, "Search", { link = "Visual" })
'';
usability = ''
vim.opt.splitright = true
vim.opt.splitbelow = true
vim.opt.tabstop = 2
vim.opt.softtabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.g.markdown_recommended_style = 0
vim.g.rust_recommended_style = 0
vim.opt.smartindent = true
vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.keymap.set("n", "<leader>y", "\"+y", {})
vim.keymap.set("v", "<leader>y", "\"+y", {})
vim.keymap.set("n", "<leader>p", "\"+p", {})
vim.keymap.set("v", "<leader>p", "\"_d\"+P", {})
vim.keymap.set("v", "p", "\"_dP", {})
vim.keymap.set("n", "<leader>s", ":%s/\\<<c-r><c-w>\\>/<c-r><c-w>/gI<left><left><left>", {})
vim.keymap.set("n", "<leader>/", "/\\c", {})
vim.keymap.set("n", "<leader>?", "?\\c", {})
vim.keymap.set("v", ">", ">gv", {})
vim.keymap.set("v", "<", "<gv", {})
vim.keymap.set("v", "J", ":m '>+1<enter>gv=gv", {})
vim.keymap.set("v", "K", ":m '<-2<enter>gv=gv", {})
vim.keymap.set("t", "<esc>", "<c-\\><c-n>", {})
vim.api.nvim_create_autocmd({"BufReadPre"}, {
pattern = {"*.nix"},
command = "setlocal commentstring=#\\ %s",
})
vim.keymap.set({"n","i","v"}, "<c-_>", ":Commentary<enter>", {})
vim.keymap.set("n", "U", vim.cmd.UndotreeToggle, {})
'';
suggestion = ''
local luasnip = require("luasnip")
local luasnip_loaders = require("luasnip.loaders.from_vscode").lazy_load()
luasnip.config.set_config({
history = true,
updateevents = "TextChanged,TextChangedI",
enable_autosnippets = true,
})
local cmp = require("cmp")
cmp.setup {
mapping = {
["<c-k>"] = cmp.mapping.select_prev_item(),
["<c-j>"] = cmp.mapping.select_next_item(),
["<c-Space>"] = cmp.mapping.confirm({ select = true }),
["<c-c>"] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
["<c-n>"] = cmp.mapping(function(fallback)
if luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' })
},
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
sources = { { name = "luasnip" }, { name = "nvim_lsp" }, { name = "path" }, { name = "buffer" }, },
window = { documentation = cmp.config.window.bordered(), },
}
local conform = require("conform")
conform.formatters.beautysh = {
prepend_args = { "-i", "2" },
}
conform.setup({
formatters_by_ft = {
typescript = { "prettier" },
javascript = { "prettier" },
css = { "prettier" },
html = { "prettier" },
markdown = { "prettier" },
json = { "prettier" },
yaml = { "prettier" },
c = { "clang_format" },
cpp = { "clang_format" },
java = { "clang_format" },
csharp = { "clang_format" },
nix = { "nixfmt" },
python = { "yapf" },
bash = { "beautysh" },
sh = { "beautysh" },
},
})
vim.keymap.set('n', '<c-f>', function()
conform.format({
bufnr = vim.api.nvim_get_current_buf(),
lsp_fallback = true,
})
end, {})
local lspconfig = require("lspconfig")
lspconfig.bashls.setup({})
lspconfig.clangd.setup({})
lspconfig.erlangls.setup({})
lspconfig.jedi_language_server.setup({})
lspconfig.nil_ls.setup({})
lspconfig.ruff_lsp.setup({})
lspconfig.rust_analyzer.setup({})
lspconfig.tsserver.setup({})
require("nvim-treesitter.configs").setup({
highlight = { enable = true, },
indent = { enable = true, } }
)
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, {})
vim.keymap.set("n", "[e", vim.diagnostic.goto_prev, {})
vim.keymap.set("n", "]e", vim.diagnostic.goto_next, {})
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
local opts = { buffer = ev.buf }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<c-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
end,
})
'';
navigation = ''
vim.keymap.set("n", "<leader>ff", ":Telescope find_files<enter>", {})
vim.keymap.set("n", "<leader>fg", ":Telescope live_grep<enter>", {})
vim.keymap.set("n", "<leader>fb", ":Telescope buffers<enter>", {})
require("harpoon").setup({ global_settings = { enter_on_sendcmd = true, }, })
local harpoon_ui = require("harpoon.ui")
local harpoon_mark = require("harpoon.mark")
local harpoon_cmd_ui = require("harpoon.cmd-ui")
local harpoon_term = require("harpoon.term")
require("telescope").load_extension("harpoon")
vim.keymap.set("n", "<leader>1", function() harpoon_ui.nav_file(1) end, {})
vim.keymap.set("n", "<leader>2", function() harpoon_ui.nav_file(2) end, {})
vim.keymap.set("n", "<leader>3", function() harpoon_ui.nav_file(3) end, {})
vim.keymap.set("n", "<leader>4", function() harpoon_ui.nav_file(4) end, {})
vim.keymap.set("n", "<leader>5", function() harpoon_ui.nav_file(5) end, {})
vim.keymap.set("n", "<leader>a", function() harpoon_mark.add_file() end, {})
vim.keymap.set("n", "<leader>mm", function() harpoon_ui.toggle_quick_menu() end, {})
vim.keymap.set("n", "<leader>cc", function() harpoon_term.sendCommand(1,1) end, {})
vim.keymap.set("n", "<leader>c2", function() harpoon_term.sendCommand(1,2) end, {})
vim.keymap.set("n", "<leader>c3", function() harpoon_term.sendCommand(1,3) end, {})
vim.keymap.set("n", "<leader>c4", function() harpoon_term.sendCommand(1,4) end, {})
vim.keymap.set("n", "<leader>c5", function() harpoon_term.sendCommand(1,5) end, {})
vim.keymap.set("n", "<leader>cm", function() harpoon_cmd_ui.toggle_quick_menu() end, {})
vim.keymap.set("n", "<leader>t", function() harpoon_term.gotoTerminal(1) end, {})
vim.keymap.set("n", "<c-t>", function() harpoon_term.gotoTerminal(2) end, {})
vim.keymap.set("n", "<c-u>", function() harpoon_term.gotoTerminal(3) end, {})
vim.keymap.set("n", "<c-u><c-u>", function() harpoon_term.gotoTerminal(4) end, {})
vim.keymap.set("n", "<c-u><c-u><c-u>", function() harpoon_term.gotoTerminal(5) end, {})
vim.keymap.set("n", "<c-u><c-u><c-u><c-u>", function() harpoon_term.gotoTerminal(6) end, {})
vim.keymap.set("n", "<c-u><c-u><c-u><c-u><c-u>", function() harpoon_term.gotoTerminal(7) end, {})
'';
other = ''
vim.api.nvim_create_autocmd({"BufReadPre"}, {
pattern = {"*.png", "*.jpg", "*.pdf"},
command = "silent !xdg-open '%' & disown",
})
vim.api.nvim_create_autocmd({"BufReadPost"}, {
pattern = {"*.png", "*.jpg", "*.pdf"},
command = "bdelete",
})
vim.opt.undofile = true
local path = os.getenv("NVIM_UNDODIR")
if path == nil then
local state_home = os.getenv("XDG_STATE_HOME")
if state_home == nil then
state_home = vim.fn.expand("~") .. "/.local/state"
end
path = state_home .. "/nvim/undo/"
end
vim.opt.undodir = path
'';
in ''
lua << EOF
${usability}
${visual}
${navigation}
${suggestion}
${other}
EOF
'';
packages.myVimPackage = with pkgs.vimPlugins; {
start = [
cmp_luasnip
cmp-buffer
cmp-cmdline
cmp-path
cmp-nvim-lsp
conform-nvim
friendly-snippets
vim-fugitive
harpoon
lualine-nvim
luasnip
nvim-cmp
nvim-lspconfig
(nvim-treesitter.withPlugins (plugins:
with plugins; [
bash
c
css
elm
erlang
haskell
html
java
javascript
lua
markdown
nix
python
r
rust
typescript
]))
telescope-nvim
undotree
vim-commentary
vim-prettier
vim-repeat
zen-mode-nvim
];
};
};
defaultEditor = true;
enable = true;
};
}

View File

@ -105,15 +105,61 @@ in {
};
};
};
imports = [
./components/bootloader.nix
./components/programs/neovim.nix
./lwad
];
imports = [ ./components/bootloader.nix ./lwad ];
lwad = {
applications = {
btop.enable = true;
git.enable = true;
neovim = {
commentary.enable = true;
completion.enable = true;
enable = true;
formatting = {
enable = true;
formatters =
[ "beautysh" "clang_format" "nixfmt" "prettier" "rustfmt" "yapf" ];
};
fugitive.enable = true;
harpoon.enable = true;
lsp = {
enable = true;
servers = [
"bash"
"clangd"
"erlang"
"jedi"
"nil"
"ruff"
"rust-analyzer"
"typescript"
];
};
snippets.enable = true;
telescope.enable = true;
undotree.enable = true;
zenmode.enable = true;
treeSitter = {
enable = true;
languages = [
"bash"
"c"
"css"
"elm"
"erlang"
"haskell"
"html"
"java"
"javascript"
"lua"
"markdown"
"nix"
"python"
"r"
"rust"
"typescript"
];
};
};
task = {
dataDir = config.home-manager.users.${username}.home.homeDirectory
+ "/Documents/tasks";

View File

@ -1,5 +1,5 @@
{ ... }:
{
imports = [ ./btop.nix ./git.nix ./task.nix ];
imports = [ ./btop.nix ./git.nix ./neovim ./task.nix ];
}

View File

@ -0,0 +1,118 @@
vim.opt.signcolumn = "no"
vim.opt.number = true
vim.opt.relativenumber = true
vim.api.nvim_create_autocmd({"TermOpen"}, {
pattern = {"*"},
command = "setlocal nonumber norelativenumber",
})
vim.opt.ignorecase = false
vim.opt.hlsearch = false
vim.opt.incsearch = true
vim.opt.scrolloff = 2
vim.opt.wrap = false
-- Popup menu height.
vim.opt.pumheight = 10
-- Mode indicator.
vim.opt.showmode = false
vim.opt.shortmess = "acFIoOsW"
vim.keymap.set("n", "<leader>z", ":ZenMode<enter>", {})
local colors = {
background = nil,
white = "#FFFFFF",
red = "#FF0000",
yellow = "#FFFF00",
black = "#000000",
lightgrey = "#888888",
blue = "#0000FF"
}
require("lualine").setup {
options = {
icons_enabled = true,
theme = {
normal = {
a = { bg = colors.white, fg = colors.black },
b = { bg = colors.lightgrey, fg = colors.white },
c = { bg = colors.bg, fg = colors.white },
y = { bg = colors.lightgrey, fg = colors.white },
z = { bg = colors.white, fg = colors.black }
},
command = {
a = { bg = colors.blue, fg = colors.black },
b = { bg = colors.lightgrey, fg = colors.white },
c = { bg = colors.bg, fg = colors.white },
y = { bg = colors.lightgrey, fg = colors.white },
z = { bg = colors.white, fg = colors.black }
},
insert = {
a = { bg = colors.red, fg = colors.white },
b = { bg = colors.lightgrey, fg = colors.white },
c = { bg = colors.bg, fg = colors.white },
y = { bg = colors.lightgrey, fg = colors.white },
z = { bg = colors.white, fg = colors.black }
},
visual = {
a = { bg = colors.yellow, fg = colors.black },
b = { bg = colors.lightgrey, fg = colors.white },
c = { bg = colors.bg, fg = colors.white },
y = { bg = colors.lightgrey, fg = colors.white },
z = { bg = colors.white, fg = colors.black }
},
replace = {
a = { bg = colors.black, fg = colors.white },
b = { bg = colors.lightgrey, fg = colors.white },
c = { bg = colors.bg, fg = colors.white },
y = { bg = colors.lightgrey, fg = colors.white },
z = { bg = colors.white, fg = colors.black }
}
},
component_separators = { left = "", right = ""},
section_separators = { left = "", right = ""},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
}
},
sections = {
lualine_a = {"mode"},
lualine_b = {"branch", "diff"},
lualine_c = {"diagnostics"},
lualine_x = {},
lualine_y = {"progress"},
lualine_z = {"filetype", "filename"}
},
inactive_sections = {
lualine_a = {},
lualine_b = {"branch", "diff"},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {"filetype", "filename"}
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {}
}
vim.o.background = 'dark'
if vim.fn.exists('syntax_on') then
vim.cmd('syntax reset')
end
vim.g.colors_name = 'translucent'
vim.api.nvim_set_hl(0, "FloatBorder", { fg = colors.white, bg = nil })
vim.api.nvim_set_hl(0, "PMenu", { ctermfg = "white", ctermbg = 242 })
vim.api.nvim_set_hl(0, "PMenuSbar", { ctermbg = 242 })
vim.api.nvim_set_hl(0, "PMenuSel", { ctermfg = 242, ctermbg = "white" })
vim.api.nvim_set_hl(0, "NormalFloat", { ctermfg = "white", ctermbg = nil })
vim.api.nvim_set_hl(0, "Search", { link = "Visual" })

View File

@ -0,0 +1,5 @@
vim.api.nvim_create_autocmd({"BufReadPre"}, {
pattern = {"*.nix"},
command = "setlocal commentstring=#\\ %s",
})
vim.keymap.set({"n","i","v"}, "<c-_>", ":Commentary<enter>", {})

View File

@ -0,0 +1,31 @@
local luasnip = require("luasnip")
local luasnip_loaders = require("luasnip.loaders.from_vscode").lazy_load()
luasnip.config.set_config({
history = true,
updateevents = "TextChanged,TextChangedI",
enable_autosnippets = true,
})
local cmp = require("cmp")
cmp.setup {
mapping = {
["<c-k>"] = cmp.mapping.select_prev_item(),
["<c-j>"] = cmp.mapping.select_next_item(),
["<c-Space>"] = cmp.mapping.confirm({ select = true }),
["<c-c>"] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
["<c-n>"] = cmp.mapping(function(fallback)
if luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' })
},
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
sources = { { name = "luasnip" }, { name = "nvim_lsp" }, { name = "path" }, { name = "buffer" }, },
window = { documentation = cmp.config.window.bordered(), },
}

View File

@ -0,0 +1,197 @@
{ config, lib, pkgs, ... }:
with lib; {
options.lwad.applications.neovim = {
commentary.enable = mkEnableOption "commentary";
completion.enable = mkEnableOption "completion";
enable = mkEnableOption "neovim";
formatting = {
enable = mkEnableOption "formatting";
formatters = mkOption {
default = [ ];
description = "List of formatters.";
type = types.listOf (types.enum [
"beautysh"
"clang_format"
"nixfmt"
"prettier"
"rustfmt"
"yapf"
]);
};
};
fugitive.enable = mkEnableOption "fugitive";
harpoon.enable = mkEnableOption "harpoon";
lsp = {
enable = mkEnableOption "lsp";
servers = mkOption {
default = [ ];
description = "List of language servers.";
type = types.listOf (types.enum [
"bash"
"clangd"
"erlang"
"jedi"
"nil"
"ruff"
"rust-analyzer"
"typescript"
]);
};
};
snippets.enable = mkEnableOption "snippets";
telescope.enable = mkEnableOption "telescope";
treeSitter = {
enable = mkEnableOption "treesitter";
languages = mkOption {
default = [ ];
description = "List of languages to enable treesitter for.";
type = types.listOf types.str;
};
};
undotree.enable = mkEnableOption "undotree";
zenmode.enable = mkEnableOption "zenmode";
};
config = let
cfg = config.lwad.applications.neovim;
hasFormatter = (formatter: statement:
optional (builtins.elem formatter cfg.formatting.formatters) statement);
hasLsp = (server: statement:
optional (builtins.elem server cfg.lsp.servers) statement);
in mkIf cfg.enable {
environment = {
systemPackages = flatten [
(optionals cfg.formatting.enable (with pkgs; [
(hasFormatter "beautysh" beautysh)
(hasFormatter "clang_format" libclang)
(hasFormatter "nixfmt" nixfmt)
(hasFormatter "prettier" nodePackages.prettier)
(hasFormatter "rustfmt" rustfmt)
(hasFormatter "yapf" yapf)
]))
(optionals cfg.lsp.enable (with pkgs; [
(hasLsp "bash" nodePackages.bash-language-server)
(hasLsp "clangd" libclang)
(hasLsp "erlang" erlang-ls)
(hasLsp "jedi" python310Packages.jedi-language-server)
(hasLsp "nil" nil)
(hasLsp "ruff" ruff-lsp)
(hasLsp "rust-analyzer" rust-analyzer)
(hasLsp "typescript" nodePackages.typescript-language-server)
]))
];
variables.path = mkIf (builtins.elem "clangd" cfg.lsp.servers)
"${pkgs.clang-tools}/bin:$PATH";
};
programs.neovim = mkIf cfg.enable {
configure = {
customRC = concatLines (flatten [
"lua << EOF"
(fileContents ./aesthetic.lua)
(fileContents ./defaults.lua)
(fileContents ./keymaps.lua)
(optional cfg.commentary.enable (fileContents ./commentary.lua))
(optional cfg.completion.enable (fileContents ./completion.lua))
(optional cfg.harpoon.enable (fileContents ./harpoon.lua))
(optional cfg.telescope.enable (fileContents ./telescope.lua))
(optional cfg.treeSitter.enable (fileContents ./treesitter.lua))
(optional cfg.undotree.enable (fileContents ./undotree.lua))
(optionals
(cfg.formatting.enable && (length cfg.formatting.formatters != 0)) [
''local conform = require("conform")''
(hasFormatter "beautysh" ''
conform.formatters.beautysh = {
prepend_args = { "-i", "2" },
}
'')
''
conform.setup({
formatters_by_ft = {
''
(hasFormatter "beautysh" ''
bash = { "beautysh" },
sh = { "beautysh" },
'')
(hasFormatter "clang_format" ''
c = { "clang_format" },
cpp = { "clang_format" },
csharp = { "clang_format" },
java = { "clang_format" },
'')
(hasFormatter "nixfmt" ''
nix = { "nixfmt" },
'')
(hasFormatter "prettier" ''
css = { "prettier" },
html = { "prettier" },
javascript = { "prettier" },
json = { "prettier" },
markdown = { "prettier" },
typescript = { "prettier" },
yaml = { "prettier" },
'')
(hasFormatter "rustfmt" ''
rust = { "rustfmt" },
'')
(hasFormatter "yapf" ''
python = { "yapf" },
'')
''
},
})
''
(fileContents ./formatting.lua)
])
(optionals (cfg.lsp.enable && (length cfg.lsp.servers != 0)) [
''local lspconfig = require("lspconfig")''
(hasLsp "bash" "lspconfig.bashls.setup({})")
(hasLsp "clangd" "lspconfig.clangd.setup({})")
(hasLsp "erlang" "lspconfig.erlangls.setup({})")
(hasLsp "jedi" "lspconfig.jedi_language_server.setup({})")
(hasLsp "nil" "lspconfig.nil_ls.setup({})")
(hasLsp "ruff" "lspconfig.ruff_lsp.setup({})")
(hasLsp "rust-analyzer" "lspconfig.rust_analyzer.setup({})")
(hasLsp "typescript" "lspconfig.tsserver.setup({})")
(fileContents ./lsp.lua)
])
"EOF"
]);
packages.myVimPackage.start = with pkgs.vimPlugins;
flatten [
(nvim-treesitter.withPlugins (plugins:
map (language: getAttr language plugins)
(optionals cfg.treeSitter.enable cfg.treeSitter.languages)))
(optional cfg.formatting.enable conform-nvim)
(optionals cfg.completion.enable [
(optional cfg.lsp.enable cmp-nvim-lsp)
(optional cfg.snippets.enable cmp_luasnip)
cmp-buffer
cmp-cmdline
cmp-path
nvim-cmp
])
(optional cfg.snippets.enable luasnip)
(optional cfg.lsp.enable nvim-lspconfig)
(optional cfg.fugitive.enable vim-fugitive)
(optional cfg.harpoon.enable harpoon)
lualine-nvim
(optional cfg.telescope.enable telescope-nvim)
(optional cfg.undotree.enable undotree)
(optional cfg.commentary.enable vim-commentary)
(hasFormatter "prettier" vim-prettier)
vim-repeat
(optional cfg.zenmode.enable zen-mode-nvim)
];
};
defaultEditor = true;
enable = true;
};
};
}

View File

@ -0,0 +1,40 @@
vim.opt.splitright = true
vim.opt.splitbelow = true
vim.opt.tabstop = 2
vim.opt.softtabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.g.markdown_recommended_style = 0
vim.g.rust_recommended_style = 0
vim.opt.smartindent = true
vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.keymap.set("v", "p", "\"_dP", {})
vim.keymap.set("v", ">", ">gv", {})
vim.keymap.set("v", "<", "<gv", {})
vim.keymap.set("t", "<esc>", "<c-\\><c-n>", {})
vim.api.nvim_create_autocmd({"BufReadPre"}, {
pattern = {"*.png", "*.jpg", "*.pdf"},
command = "silent !xdg-open '%' & disown",
})
vim.api.nvim_create_autocmd({"BufReadPost"}, {
pattern = {"*.png", "*.jpg", "*.pdf"},
command = "bdelete",
})
vim.opt.undofile = true
local path = os.getenv("NVIM_UNDODIR")
if path == nil then
local state_home = os.getenv("XDG_STATE_HOME")
if state_home == nil then
state_home = vim.fn.expand("~") .. "/.local/state"
end
path = state_home .. "/nvim/undo/"
end
vim.opt.undodir = path

View File

@ -0,0 +1,6 @@
vim.keymap.set('n', '<c-f>', function()
conform.format({
bufnr = vim.api.nvim_get_current_buf(),
lsp_fallback = true,
})
end, {})

View File

@ -0,0 +1,25 @@
require("harpoon").setup({ global_settings = { enter_on_sendcmd = true, }, })
local harpoon_ui = require("harpoon.ui")
local harpoon_mark = require("harpoon.mark")
local harpoon_cmd_ui = require("harpoon.cmd-ui")
local harpoon_term = require("harpoon.term")
vim.keymap.set("n", "<leader>1", function() harpoon_ui.nav_file(1) end, {})
vim.keymap.set("n", "<leader>2", function() harpoon_ui.nav_file(2) end, {})
vim.keymap.set("n", "<leader>3", function() harpoon_ui.nav_file(3) end, {})
vim.keymap.set("n", "<leader>4", function() harpoon_ui.nav_file(4) end, {})
vim.keymap.set("n", "<leader>5", function() harpoon_ui.nav_file(5) end, {})
vim.keymap.set("n", "<leader>a", function() harpoon_mark.add_file() end, {})
vim.keymap.set("n", "<leader>mm", function() harpoon_ui.toggle_quick_menu() end, {})
vim.keymap.set("n", "<leader>cc", function() harpoon_term.sendCommand(1,1) end, {})
vim.keymap.set("n", "<leader>c2", function() harpoon_term.sendCommand(1,2) end, {})
vim.keymap.set("n", "<leader>c3", function() harpoon_term.sendCommand(1,3) end, {})
vim.keymap.set("n", "<leader>c4", function() harpoon_term.sendCommand(1,4) end, {})
vim.keymap.set("n", "<leader>c5", function() harpoon_term.sendCommand(1,5) end, {})
vim.keymap.set("n", "<leader>cm", function() harpoon_cmd_ui.toggle_quick_menu() end, {})
vim.keymap.set("n", "<leader>t", function() harpoon_term.gotoTerminal(1) end, {})
vim.keymap.set("n", "<c-t>", function() harpoon_term.gotoTerminal(2) end, {})
vim.keymap.set("n", "<c-u>", function() harpoon_term.gotoTerminal(3) end, {})
vim.keymap.set("n", "<c-u><c-u>", function() harpoon_term.gotoTerminal(4) end, {})
vim.keymap.set("n", "<c-u><c-u><c-u>", function() harpoon_term.gotoTerminal(5) end, {})
vim.keymap.set("n", "<c-u><c-u><c-u><c-u>", function() harpoon_term.gotoTerminal(6) end, {})
vim.keymap.set("n", "<c-u><c-u><c-u><c-u><c-u>", function() harpoon_term.gotoTerminal(7) end, {})

View File

@ -0,0 +1,12 @@
vim.keymap.set("n", "<leader>s", ":%s/\\<<c-r><c-w>\\>/<c-r><c-w>/gI<left><left><left>", {})
vim.keymap.set("n", "<leader>y", "\"+y", {})
vim.keymap.set("v", "<leader>y", "\"+y", {})
vim.keymap.set("n", "<leader>p", "\"+p", {})
vim.keymap.set("v", "<leader>p", "\"_d\"+P", {})
vim.keymap.set("n", "<leader>/", "/\\c", {})
vim.keymap.set("n", "<leader>?", "?\\c", {})
vim.keymap.set("v", "J", ":m '>+1<enter>gv=gv", {})
vim.keymap.set("v", "K", ":m '<-2<enter>gv=gv", {})

View File

@ -0,0 +1,17 @@
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, {})
vim.keymap.set("n", "[e", vim.diagnostic.goto_prev, {})
vim.keymap.set("n", "]e", vim.diagnostic.goto_next, {})
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
local opts = { buffer = ev.buf }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<c-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
end,
})

View File

@ -0,0 +1,3 @@
vim.keymap.set("n", "<leader>ff", ":Telescope find_files<enter>", {})
vim.keymap.set("n", "<leader>fg", ":Telescope live_grep<enter>", {})
vim.keymap.set("n", "<leader>fb", ":Telescope buffers<enter>", {})

View File

@ -0,0 +1,4 @@
require("nvim-treesitter.configs").setup({
highlight = { enable = true, },
indent = { enable = true, } }
)

View File

@ -0,0 +1 @@
vim.keymap.set("n", "U", vim.cmd.UndotreeToggle, {})