nvim: the epic config restructure

This commit is contained in:
2023-07-08 15:20:43 +03:00
parent 43a54ad044
commit 9a81f16153
31 changed files with 384 additions and 495 deletions

View File

@ -1,4 +1,3 @@
require("plugins") require("config.options")
require("options") require("config.mappings")
require("mappings") require("config.plugins")
require("colors")

View File

@ -1,2 +0,0 @@
-- vim.cmd("colorscheme wal")
-- vim.cmd("colorscheme monokai")

View File

@ -0,0 +1,13 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup("plugins")

View File

@ -1,274 +0,0 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{
"echasnovski/mini.nvim",
config = function()
require("plugins.mini")
end,
},
--
-- dev
--
-- lspconfig
{
"neovim/nvim-lspconfig",
config = function()
require("plugins.lsp")
end,
},
-- nvim lint
{
"mfussenegger/nvim-lint",
config = function()
require("plugins.lint")
end,
},
-- cmp
{
"hrsh7th/nvim-cmp",
config = function()
require("plugins.cmp")
end,
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-vsnip",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-nvim-lsp-signature-help",
},
},
-- snippets
{
"hrsh7th/vim-vsnip",
config = function()
require("plugins.vsnip")
end,
},
"rafamadriz/friendly-snippets",
-- autopairs
{
"windwp/nvim-autopairs",
config = function()
require("plugins.autopairs")
end,
},
-- treesitter
{
"nvim-treesitter/nvim-treesitter",
config = function()
require("plugins.treesitter")
end,
},
{
"nvim-treesitter/nvim-treesitter-context",
config = function()
require("plugins.treesitter-context")
end,
},
{
"RRethy/nvim-treesitter-textsubjects",
config = function()
require("plugins.treesitter-textobjects")
end,
},
-- formatter
{
"mhartington/formatter.nvim",
cmd = { "Format", "FormatWrite" },
config = function()
require("plugins.formatter")
end,
},
-- dap
{
"mfussenegger/nvim-dap",
config = function()
require("plugins.dap")
end,
dependencies = {
"leoluz/nvim-dap-go",
"mfussenegger/nvim-dap-python",
},
},
-- trouble
{
"folke/trouble.nvim",
cmd = { "Trouble", "TroubleToggle" },
config = function()
require("plugins.trouble")
end,
},
-- toggleterm
{
"akinsho/toggleterm.nvim",
cmd = { "ToggleTerm" },
config = function()
require("plugins.toggleterm")
end,
dependencies = {
"chomosuke/term-edit.nvim",
},
},
-- neogen
{
"danymat/neogen",
config = function()
require("plugins.neogen")
end,
},
-- neotest
{
"nvim-neotest/neotest",
config = function()
require("plugins.neotest")
end,
dependencies = {
"antoinemadec/FixCursorHold.nvim",
"nvim-neotest/neotest-python",
},
keys = {
"<leader>n",
},
},
-- refactoring
{
"ThePrimeagen/refactoring.nvim",
config = function()
require("plugins.refactoring")
end,
keys = {
"<leader>r",
},
},
--
-- git
--
-- "tpope/vim-fugitive",
{
"TimUntersberger/neogit",
config = function()
require("plugins.neogit")
end,
},
"sindrets/diffview.nvim",
--
-- files (and more)
--
-- telescope
{
"nvim-telescope/telescope.nvim",
config = function()
require("plugins.telescope")
end,
dependencies = {
"nvim-lua/plenary.nvim",
},
},
-- nvim tree
{
"kyazdani42/nvim-tree.lua",
config = function()
require("plugins.nvim-tree")
end,
dependencies = {
"kyazdani42/nvim-web-devicons",
},
cmd = { "NvimTreeOpen", "NvimTreeToggle" },
},
--
-- looks
--
-- lualine
{
"hoob3rt/lualine.nvim",
config = function()
require("plugins.lualine")
end,
},
--
-- colorscheme
--
{
"nekonako/xresources-nvim",
config = function()
require('xresources')
end,
},
--
-- telekasten
--
{
"renerocksai/telekasten.nvim",
config = function()
require("plugins.telekasten")
end,
dependencies = {
"telescope.nvim",
},
key = {
"<leader>z",
},
ft = {
"markdown",
},
},
"renerocksai/calendar-vim",
{
"shortcuts/no-neck-pain.nvim",
config = function()
require("plugins.no-neck-pain")
end,
},
{
"folke/which-key.nvim",
key = {
"<leader>",
},
config = function()
require("plugins.which-key")
end,
},
})

View File

@ -1,6 +1,11 @@
-- autopairs return {
require("nvim-autopairs").setup({}) "windwp/nvim-autopairs",
-- insert () after selecting functions config = function()
local cmp_autopairs = require("nvim-autopairs.completion.cmp") -- autopairs
local cmp = require("cmp") require("nvim-autopairs").setup({})
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } })) -- insert () after selecting functions
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local cmp = require("cmp")
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } }))
end,
}

View File

@ -1 +0,0 @@
vim.g.calendar_no_mappings = true

View File

@ -1,9 +1,22 @@
vim.opt.completeopt = { "menuone", "noselect" } return {
"hrsh7th/nvim-cmp",
config = function()
require("plugins.cmp")
end,
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-vsnip",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-nvim-lsp-signature-help",
},
opts = function()
vim.opt.completeopt = { "menuone", "noselect" }
local cmp = require("cmp") local cmp = require("cmp")
local neogen = require("neogen") local neogen = require("neogen")
cmp.setup({ cmp.setup({
snippet = { snippet = {
expand = function(args) expand = function(args)
vim.fn["vsnip#anonymous"](args.body) vim.fn["vsnip#anonymous"](args.body)
@ -49,4 +62,6 @@ cmp.setup({
{ name = "vsnip" }, { name = "vsnip" },
{ name = "orgmode" }, { name = "orgmode" },
}, },
}) })
end,
}

View File

@ -1,2 +1,11 @@
require("dap-go").setup() return {
require("dap-python").setup() "mfussenegger/nvim-dap",
config = function()
require("dap-go").setup()
require("dap-python").setup()
end,
dependencies = {
"leoluz/nvim-dap-go",
"mfussenegger/nvim-dap-python",
},
}

View File

@ -1,4 +1,8 @@
require("formatter").setup({ return {
"mhartington/formatter.nvim",
cmd = { "Format", "FormatWrite" },
config = function()
require("formatter").setup({
filetype = { filetype = {
lua = { lua = {
require("formatter.filetypes.lua").stylua, require("formatter.filetypes.lua").stylua,
@ -20,4 +24,6 @@ require("formatter").setup({
require("formatter.filetypes.toml").taplo, require("formatter.filetypes.toml").taplo,
}, },
}, },
}) })
end,
}

View File

@ -1,6 +1,11 @@
require("lint").linters_by_ft = { return {
"mfussenegger/nvim-lint",
config = function()
require("lint").linters_by_ft = {
python = { "mypy" }, python = { "mypy" },
rust = { "ruff" }, rust = { "ruff" },
} }
vim.cmd("au BufWrite <buffer> lua require('lint').try_lint()") vim.cmd("au BufWrite <buffer> lua require('lint').try_lint()")
end,
}

View File

@ -1,9 +1,14 @@
local lsp = require("lspconfig") return {
{
-- lsp.jedi_language_server.setup{} "neovim/nvim-lspconfig",
lsp.pyright.setup{} config = function()
lsp.gopls.setup{} lsp = require("lspconfig")
lsp.rust_analyzer.setup{} lsp.pyright.setup({})
lsp.clangd.setup{} lsp.gopls.setup({})
lsp.lua_ls.setup{} lsp.rust_analyzer.setup({})
lsp.solargraph.setup{} lsp.clangd.setup({})
lsp.lua_ls.setup({})
lsp.solargraph.setup({})
end,
},
}

View File

@ -1,8 +1,12 @@
-- lualine colorscheme return {
require("lualine").setup({ "hoob3rt/lualine.nvim",
config = function()
require("lualine").setup({
options = { options = {
theme = "auto", theme = "auto",
section_separators = { "", "" }, section_separators = { "", "" },
component_separators = { "", "" }, component_separators = { "", "" },
}, },
}) })
end,
}

View File

@ -1,17 +0,0 @@
require("mini.ai").setup()
require("mini.bracketed").setup()
require("mini.comment").setup()
require("mini.move").setup()
require("mini.starter").setup()
require("mini.tabline").setup()
require("mini.surround").setup({
mappings = {
add = "<space>sa",
delete = "<space>sd",
find = "<space>sf",
find_left = "<space>sF",
highlight = "<space>sh",
replace = "<space>sr",
update_n_lines = "<space>sn",
},
})

View File

@ -1,4 +1,7 @@
require("neogen").setup({ return {
"danymat/neogen",
config = function()
require("neogen").setup({
languages = { languages = {
python = { python = {
template = { template = {
@ -6,4 +9,6 @@ require("neogen").setup({
}, },
}, },
}, },
}) })
end,
}

View File

@ -1,7 +1,15 @@
local neogit = require("neogit") return {
"TimUntersberger/neogit",
dependencies = {
"sindrets/diffview.nvim",
},
config = function()
local neogit = require("neogit")
neogit.setup({ neogit.setup({
integrations = { integrations = {
diffview = true, diffview = true,
}, },
}) })
end,
}

View File

@ -1,7 +1,19 @@
require("neotest").setup({ return {
"nvim-neotest/neotest",
config = function()
require("neotest").setup({
adapters = { adapters = {
require("neotest-python")({ require("neotest-python")({
runner = "pytest", runner = "pytest",
}), }),
}, },
}) })
end,
dependencies = {
"antoinemadec/FixCursorHold.nvim",
"nvim-neotest/neotest-python",
},
keys = {
"<leader>n",
},
}

View File

@ -1,7 +1,12 @@
require("no-neck-pain").setup({ return {
"shortcuts/no-neck-pain.nvim",
config = function()
require("no-neck-pain").setup({
buffers = { buffers = {
right = { right = {
enabled = false, enabled = false,
}, },
}, },
}) })
end,
}

View File

@ -1,13 +1,22 @@
-- nvim tree return {
require("nvim-tree").setup({ "kyazdani42/nvim-tree.lua",
config = function()
-- nvim tree
require("nvim-tree").setup({
update_cwd = true, update_cwd = true,
diagnostics = { diagnostics = {
enable = true, enable = true,
}, },
}) })
-- close tab/vim when nvim-tree is the last window in the tab -- close tab/vim when nvim-tree is the last window in the tab
vim.api.nvim_create_autocmd("BufEnter", { vim.api.nvim_create_autocmd("BufEnter", {
pattern = "*", pattern = "*",
command = "if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif", command = "if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif",
}) })
end,
dependencies = {
"kyazdani42/nvim-web-devicons",
},
cmd = { "NvimTreeOpen", "NvimTreeToggle" },
}

View File

@ -1 +1,9 @@
require("refactoring").setup() return {
"ThePrimeagen/refactoring.nvim",
config = function()
require("refactoring").setup()
end,
keys = {
"<leader>r",
},
}

View File

@ -1,2 +1,17 @@
local home = vim.fn.expand("~/docs/zettelkasten") return {
require("telekasten").setup({ home = home }) "renerocksai/telekasten.nvim",
config = function()
local home = vim.fn.expand("~/docs/zettelkasten")
require("telekasten").setup({ home = home })
vim.g.calendar_no_mappings = true
end,
dependencies = {
"renerocksai/calendar-vim",
},
key = {
"<leader>z",
},
ft = {
"markdown",
},
}

View File

@ -1,5 +1,7 @@
-- telescope settings return {
require("telescope").setup({ "nvim-telescope/telescope.nvim",
config = function()
require("telescope").setup({
defaults = { defaults = {
-- sorting -- sorting
file_sorter = require("telescope.sorters").get_fzy_sorter, file_sorter = require("telescope.sorters").get_fzy_sorter,
@ -10,4 +12,9 @@ require("telescope").setup({
enable_preview = true, enable_preview = true,
}, },
}, },
}) })
end,
dependencies = {
"nvim-lua/plenary.nvim",
},
}

View File

@ -1,7 +1,16 @@
vim.o.hidden = true return {
require("toggleterm").setup({ "akinsho/toggleterm.nvim",
cmd = { "ToggleTerm" },
config = function()
vim.o.hidden = true
require("toggleterm").setup({
start_in_insert = false, start_in_insert = false,
}) })
require("term-edit").setup({ require("term-edit").setup({
prompt_end = "%$ ", prompt_end = "%$ ",
}) })
end,
dependencies = {
"chomosuke/term-edit.nvim",
},
}

View File

@ -1 +1,18 @@
require("treesitter-context").setup() return {
"nvim-treesitter/nvim-treesitter-context",
"RRethy/nvim-treesitter-textsubjects",
config = function()
require("treesitter-context").setup()
require("nvim-treesitter.configs").setup({
textsubjects = {
enable = true,
prev_selection = ",", -- (Optional) keymap to select the previous selection
keymaps = {
["."] = "textsubjects-smart",
[";"] = "textsubjects-container-outer",
["i;"] = "textsubjects-container-inner",
},
},
})
end,
}

View File

@ -1,11 +0,0 @@
require("nvim-treesitter.configs").setup({
textsubjects = {
enable = true,
prev_selection = ",", -- (Optional) keymap to select the previous selection
keymaps = {
["."] = "textsubjects-smart",
[";"] = "textsubjects-container-outer",
["i;"] = "textsubjects-container-inner",
},
},
})

View File

@ -1,5 +1,10 @@
require("nvim-treesitter.configs").setup({ return {
"nvim-treesitter/nvim-treesitter",
config = function()
require("nvim-treesitter.configs").setup({
highlight = { highlight = {
enable = true, enable = true,
}, },
}) })
end,
}

View File

@ -1 +1,8 @@
require("trouble").setup() return {
"folke/trouble.nvim",
cmd = { "Trouble", "TroubleToggle" },
config = function()
require("plugins.trouble")
require("trouble").setup()
end,
}

View File

@ -1,7 +1,19 @@
-- jumpable mappings return {
vim.api.nvim_exec([[ "hrsh7th/vim-vsnip",
dependencies = {
"rafamadriz/friendly-snippets",
},
config = function()
-- jumpable mappings
vim.api.nvim_exec(
[[
imap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>' imap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'
smap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>' smap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'
imap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>' imap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'
smap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>' smap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'
]], false) ]],
false
)
end,
}

View File

@ -1,5 +1,11 @@
local wk = require("which-key") return {
wk.register({ "folke/which-key.nvim",
key = {
"<leader>",
},
config = function()
local wk = require("which-key")
wk.register({
a = { name = "actions" }, a = { name = "actions" },
c = { name = "terminal" }, c = { name = "terminal" },
d = { name = "debug" }, d = { name = "debug" },
@ -9,4 +15,6 @@ wk.register({
r = { name = "refactoring" }, r = { name = "refactoring" },
t = { name = "telescope" }, t = { name = "telescope" },
v = { name = "vcs" }, v = { name = "vcs" },
}, { prefix = "<leader>" }) }, { prefix = "<leader>" })
end,
}

View File

@ -0,0 +1,6 @@
return {
"nekonako/xresources-nvim",
config = function()
require("xresources")
end,
}