manage nvim with home manager
This commit is contained in:
parent
ce32eab887
commit
cedd2c1983
8 changed files with 4 additions and 0 deletions
78
nix/home/nvim/init.lua
Normal file
78
nix/home/nvim/init.lua
Normal file
|
@ -0,0 +1,78 @@
|
|||
require("plugin_specs")
|
||||
|
||||
local keymap = vim.keymap
|
||||
local opt = vim.opt
|
||||
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
vim.opt.termguicolors = true
|
||||
require("nvim-tree").setup()
|
||||
|
||||
require("lualine").setup {
|
||||
options = {
|
||||
theme = "auto",
|
||||
icons_enabled = true,
|
||||
globalstatus = true,
|
||||
}
|
||||
}
|
||||
|
||||
require("gitsigns").setup()
|
||||
|
||||
opt.tabstop = 2
|
||||
opt.softtabstop = 2
|
||||
opt.shiftwidth = 2
|
||||
opt.expandtab = true
|
||||
opt.relativenumber = true
|
||||
opt.ignorecase = true
|
||||
opt.smartcase = true
|
||||
opt.scrolloff = 3
|
||||
opt.confirm = true
|
||||
opt.history = 500
|
||||
opt.undofile = true
|
||||
opt.termguicolors = true
|
||||
opt.showmode = false
|
||||
opt.mouse = ""
|
||||
|
||||
vim.cmd.colorscheme "tokyonight-night"
|
||||
|
||||
keymap.set("n", "<space>s", require("nvim-tree.api").tree.toggle, {
|
||||
desc = "toggle nvim-tree",
|
||||
silent = true,
|
||||
})
|
||||
|
||||
-- shortcut to command mode
|
||||
keymap.set({ "n", "x" }, ";", ":", { silent = true })
|
||||
|
||||
keymap.set("n", "<space>o", "printf('m`%so<ESC>``', v:count1)", {
|
||||
expr = true,
|
||||
desc = "insert line below without moving cursor",
|
||||
})
|
||||
|
||||
keymap.set("n", "<space>O", "printf('m`%sO<ESC>``', v:count1)", {
|
||||
expr = true,
|
||||
desc = "insert line above without moving cursor",
|
||||
})
|
||||
|
||||
keymap.set("n", "/", [[/\v]])
|
||||
|
||||
keymap.set("n", "c", '"_c')
|
||||
keymap.set("n", "C", '"_C')
|
||||
keymap.set("n", "cc", '"_cc')
|
||||
keymap.set("x", "c", '"_c')
|
||||
keymap.set("x", "p", '"_c<Esc>p')
|
||||
|
||||
-- Break inserted text into smaller undo units when we insert some punctuation chars.
|
||||
local undo_ch = { ",", ".", "!", "?", ";", ":" }
|
||||
for _, ch in ipairs(undo_ch) do
|
||||
keymap.set("i", ch, ch .. "<c-g>u")
|
||||
end
|
||||
|
||||
keymap.set("i", "<C-A>", "<HOME>")
|
||||
keymap.set("i", "<C-E>", "<END>")
|
||||
|
||||
-- copilot
|
||||
vim.keymap.set('i', '<C-J>', 'copilot#Accept("\\<CR>")', {
|
||||
expr = true,
|
||||
replace_keycodes = false
|
||||
})
|
||||
vim.g.copilot_no_tab_map = true
|
24
nix/home/nvim/lazy-lock.json
Normal file
24
nix/home/nvim/lazy-lock.json
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
|
||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
|
||||
"cmp-omni": { "branch": "main", "commit": "4ef610bbd85a5ee4e97e09450c0daecbdc60de86" },
|
||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
|
||||
"copilot.vim": { "branch": "release", "commit": "87038123804796ca7af20d1b71c3428d858a9124" },
|
||||
"dressing.nvim": { "branch": "master", "commit": "fc78a3ca96f4db9f8893bb7e2fd9823e0780451b" },
|
||||
"fzf-lua": { "branch": "main", "commit": "0063769312e913b5de9f2db21285d806dcf4efcb" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" },
|
||||
"hop.nvim": { "branch": "master", "commit": "08ddca799089ab96a6d1763db0b8adc5320bf050" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "014d1d6d78df4e58f962158e6e00261d8632612c" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" },
|
||||
"nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "ca4d3330d386e76967e53b85953c170658255ecb" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "fc16fd4f9c5d72b45db0f45ee275db3a9a30481a" },
|
||||
"nvim-tree.lua": { "branch": "master", "commit": "db8d7ac1f524fc6f808764b29fa695c51e014aa6" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "3b8dee4293567b0b9a87360842af14669f60dd13" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "87c34abe5d1dc7c1c0a95aaaf888059c614c68ac" },
|
||||
"tokyonight.nvim": { "branch": "main", "commit": "355e2842291dbf51b2c5878e9e37281bbef09783" },
|
||||
"vim-commentary": { "branch": "master", "commit": "64a654ef4a20db1727938338310209b6a63f60c9" }
|
||||
}
|
21
nix/home/nvim/lua/config/fzf.lua
Normal file
21
nix/home/nvim/lua/config/fzf.lua
Normal file
|
@ -0,0 +1,21 @@
|
|||
local keymap = vim.keymap
|
||||
|
||||
local fzf = require("fzf-lua")
|
||||
|
||||
keymap.set("n", "<leader>ff", fzf.files, { silent = true })
|
||||
keymap.set("n", "<leader>fr", fzf.oldfiles, { silent = true })
|
||||
keymap.set("n", "<leader>fc", fzf.resume, { silent = true })
|
||||
keymap.set("n", "<leader>fs", fzf.treesitter, { silent = true })
|
||||
keymap.set("n", "<leader>fg", fzf.grep_project, { silent = true })
|
||||
|
||||
fzf.setup {
|
||||
"fzf-native",
|
||||
keymap = {
|
||||
fzf = {
|
||||
["ctrl-u"] = "half-page-up",
|
||||
["ctrl-d"] = "half-page-down",
|
||||
["ctrl-j"] = "preview-page-down",
|
||||
["ctrl-k"] = "preview-page-up",
|
||||
}
|
||||
}
|
||||
}
|
16
nix/home/nvim/lua/config/hop.lua
Normal file
16
nix/home/nvim/lua/config/hop.lua
Normal file
|
@ -0,0 +1,16 @@
|
|||
local hop = require('hop')
|
||||
local keymap = vim.keymap
|
||||
|
||||
hop.setup {
|
||||
case_insensitive = true;
|
||||
char2_fallback_key = "<CR>",
|
||||
quit_key = "<Esc",
|
||||
}
|
||||
|
||||
keymap.set({ 'n', 'v', 'o' }, 'f', "", {
|
||||
silent = true;
|
||||
noremap = true;
|
||||
callback = function()
|
||||
hop.hint_char2()
|
||||
end,
|
||||
})
|
75
nix/home/nvim/lua/config/lsp.lua
Normal file
75
nix/home/nvim/lua/config/lsp.lua
Normal file
|
@ -0,0 +1,75 @@
|
|||
local lsp = vim.lsp
|
||||
local diagnostic = vim.diagnostic
|
||||
local keymap = vim.keymap
|
||||
|
||||
keymap.set("n", "gd", lsp.buf.definition)
|
||||
keymap.set("n", "<space>rn", lsp.buf.rename)
|
||||
keymap.set("n", "gr", lsp.buf.references)
|
||||
keymap.set("n", "[d", diagnostic.goto_prev)
|
||||
keymap.set("n", "]d", diagnostic.goto_next)
|
||||
|
||||
diagnostic.config {
|
||||
signs = false,
|
||||
}
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
lspconfig.pylsp.setup { capabilities = capabilities }
|
||||
lspconfig.clangd.setup { capabilities = capabilities }
|
||||
lspconfig.vimls.setup { capabilities = capabilities }
|
||||
lspconfig.bashls.setup { capabilities = capabilities }
|
||||
lspconfig.rust_analyzer.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
lspconfig.gopls.setup {
|
||||
settings = {
|
||||
gopls = {
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
},
|
||||
staticcheck = true,
|
||||
gofumpt = true,
|
||||
}
|
||||
},
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
lspconfig.lua_ls.setup {
|
||||
capabilities = capabilities,
|
||||
on_init = function(client)
|
||||
if client.workspace_folders then
|
||||
local path = client.workspace_folders[1].name
|
||||
if vim.uv.fs_stat(path..'/.luarc.json') or vim.uv.fs_stat(path..'/.luarc.jsonc') then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using
|
||||
-- (most likely LuaJIT in the case of Neovim)
|
||||
version = 'LuaJIT'
|
||||
},
|
||||
-- Make the server aware of Neovim runtime files
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
library = {
|
||||
vim.env.VIMRUNTIME
|
||||
-- Depending on the usage, you might want to add additional paths here.
|
||||
-- "${3rd}/luv/library"
|
||||
-- "${3rd}/busted/library",
|
||||
}
|
||||
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower
|
||||
-- library = vim.api.nvim_get_runtime_file("", true)
|
||||
}
|
||||
})
|
||||
end,
|
||||
settings = {
|
||||
Lua = {}
|
||||
}
|
||||
}
|
||||
|
||||
lspconfig.nixd.setup { capabilities = capabilities }
|
||||
lspconfig.sqls.setup { capabilities = capabilities }
|
54
nix/home/nvim/lua/config/nvim-cmp.lua
Normal file
54
nix/home/nvim/lua/config/nvim-cmp.lua
Normal file
|
@ -0,0 +1,54 @@
|
|||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip");
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
["<C-e"] = cmp.mapping.abort(),
|
||||
|
||||
["<C-k>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
if luasnip.expandable() then
|
||||
luasnip.expand()
|
||||
else
|
||||
cmp.confirm({
|
||||
select = true,
|
||||
})
|
||||
end
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
|
||||
["<C-n>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.locally_jumpable(1) then
|
||||
luasnip.jump(1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
["<C-p>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
},
|
||||
sources = cmp.config.sources ({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
}, {
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
})
|
||||
}
|
99
nix/home/nvim/lua/plugin_specs.lua
Normal file
99
nix/home/nvim/lua/plugin_specs.lua
Normal file
|
@ -0,0 +1,99 @@
|
|||
-- Bootstrap lazy.nvim
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.api.nvim_echo({
|
||||
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
||||
{ out, "WarningMsg" },
|
||||
{ "\nPress any key to exit..." },
|
||||
}, true, {})
|
||||
vim.fn.getchar()
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
vim.g.mapleader = ","
|
||||
|
||||
local plugin_specs = {
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
build = ":TSUpdate",
|
||||
event = "VeryLazy",
|
||||
},
|
||||
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufRead", "BufNewFile" },
|
||||
config = function()
|
||||
require("config.lsp")
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
event = 'VeryLazy',
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-omni",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
},
|
||||
config = function()
|
||||
require("config.nvim-cmp")
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
version = "v2.*",
|
||||
build = "make install_jsregexp",
|
||||
},
|
||||
|
||||
{ "stevearc/dressing.nvim", event = "VeryLazy" },
|
||||
|
||||
{
|
||||
"nvim-tree/nvim-tree.lua",
|
||||
lazy = false,
|
||||
dependencies = {
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"ibhagwan/fzf-lua",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
config = function()
|
||||
require("config.fzf")
|
||||
end,
|
||||
},
|
||||
|
||||
{ "windwp/nvim-autopairs", event = "InsertEnter", config = true },
|
||||
|
||||
{ "tpope/vim-commentary", event = "VeryLazy" },
|
||||
|
||||
{ "folke/tokyonight.nvim", lazy = false, priority = 1000 },
|
||||
|
||||
{ "lewis6991/gitsigns.nvim"},
|
||||
|
||||
{ "nvim-lualine/lualine.nvim", dependencies = { "nvim-tree/nvim-web-devicons" } },
|
||||
|
||||
{ "github/copilot.vim", lazy = false },
|
||||
|
||||
{
|
||||
'smoka7/hop.nvim',
|
||||
version = "*",
|
||||
config = function()
|
||||
require("config.hop")
|
||||
end,
|
||||
}
|
||||
}
|
||||
|
||||
require("lazy").setup({
|
||||
spec = plugin_specs,
|
||||
rocks = { enabled = true },
|
||||
})
|
|
@ -7,4 +7,8 @@
|
|||
home.sessionVariables = {
|
||||
"EDITOR" = "nvim";
|
||||
};
|
||||
|
||||
xdg.configFile = {
|
||||
nvim.source = ../nvim;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue