Improved neovim config

This commit is contained in:
Eduard Urbach 2023-08-21 00:09:00 +02:00
parent d07a82fff2
commit 2ad93d9338
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
15 changed files with 140 additions and 53 deletions

View File

@ -5,11 +5,15 @@
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"gitsigns.nvim": { "branch": "main", "commit": "749267aaa863c30d721c9913699c5d94e0c07dd3" }, "gitsigns.nvim": { "branch": "main", "commit": "749267aaa863c30d721c9913699c5d94e0c07dd3" },
"lazy.nvim": { "branch": "main", "commit": "dac844ed617dda4f9ec85eb88e9629ad2add5e05" }, "lazy.nvim": { "branch": "main", "commit": "dac844ed617dda4f9ec85eb88e9629ad2add5e05" },
"noice.nvim": { "branch": "main", "commit": "894db25ec726d32047799d4d0a982b701bec453b" },
"nui.nvim": { "branch": "main", "commit": "9e3916e784660f55f47daa6f26053ad044db5d6a" },
"nvim-cmp": { "branch": "main", "commit": "51f1e11a89ec701221877532ee1a23557d291dd5" }, "nvim-cmp": { "branch": "main", "commit": "51f1e11a89ec701221877532ee1a23557d291dd5" },
"nvim-lspconfig": { "branch": "master", "commit": "67f151e84daddc86cc65f5d935e592f76b9f4496" }, "nvim-lspconfig": { "branch": "master", "commit": "67f151e84daddc86cc65f5d935e592f76b9f4496" },
"nvim-tree.lua": { "branch": "master", "commit": "dea82ae2071a8d6412ca31e8fc48da5accad1a1d" }, "nvim-notify": { "branch": "master", "commit": "ea9c8ce7a37f2238f934e087c255758659948e0f" },
"nvim-treesitter": { "branch": "master", "commit": "8fa7ce35afe88b8294e6ced757aa14ec98414568" }, "nvim-tree.lua": { "branch": "master", "commit": "920868dba13466586897a8f40220eca6b2caac41" },
"nvim-treesitter": { "branch": "master", "commit": "a185f8ebae9006b181e83f6569df68e7ff8aeb80" },
"nvim-web-devicons": { "branch": "master", "commit": "cfc8824cc1db316a276b36517f093baccb8e799a" }, "nvim-web-devicons": { "branch": "master", "commit": "cfc8824cc1db316a276b36517f093baccb8e799a" },
"nvterm": { "branch": "main", "commit": "5ae78fb332e92447121d2af58a6313189a7799fb" },
"onedark.nvim": { "branch": "master", "commit": "09b71d84bd2524438e48c0aa5b54d855cc72af32" }, "onedark.nvim": { "branch": "master", "commit": "09b71d84bd2524438e48c0aa5b54d855cc72af32" },
"plenary.nvim": { "branch": "master", "commit": "267282a9ce242bbb0c5dc31445b6d353bed978bb" }, "plenary.nvim": { "branch": "master", "commit": "267282a9ce242bbb0c5dc31445b6d353bed978bb" },
"telescope.nvim": { "branch": "master", "commit": "2d92125620417fbea82ec30303823e3cd69e90e8" } "telescope.nvim": { "branch": "master", "commit": "2d92125620417fbea82ec30303823e3cd69e90e8" }

View File

@ -18,7 +18,7 @@ require("lazy").setup("plugins", {
lazy = true, lazy = true,
}, },
change_detection = { change_detection = {
notify = false, notify = false
}, },
performance = { performance = {
rtp = { rtp = {

View File

@ -5,3 +5,16 @@ on("VimEnter", {
require("nvim-tree.api").tree.toggle({ focus = false }) require("nvim-tree.api").tree.toggle({ focus = false })
end, end,
}) })
on({ "TermOpen", "TermEnter" }, {
callback = function()
vim.wo.signcolumn = "no"
end,
})
on({ "BufNewFile", "BufRead" }, {
pattern = { "*.txt", "*.md" },
callback = function()
vim.lo.wrap = true
end,
})

View File

@ -1,25 +1,29 @@
local map = vim.keymap.set local map = function(mode, lhs, rhs, info)
vim.keymap.set(mode, lhs, rhs, { desc = info })
end
-- Normal mode -- Basics
map("n", "<C-n>", "<cmd>enew<cr>", { desc = "New File" }) map("n", "<C-n>", "<cmd>enew<cr>", "New File")
map("n", "<C-b>", "<cmd>NvimTreeToggle<cr>", { desc = "Toggle file explorer" }) map({ "i", "n", "s", "v" }, "<C-s>", "<cmd>w<cr><esc>", "Save file")
map("n", "<C-q>", "<cmd>qa<cr>", { desc = "Quit all" }) map("n", "<C-q>", "<cmd>qa<cr>", "Quit all")
map("n", "<leader>l", "<cmd>Lazy<cr>", { desc = "Lazy" }) map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", "Clear search")
map("n", "<leader>f", "<cmd>Telescope find_files<cr>", { desc = "Find files" })
map("n", "<leader>r", "<cmd>Telescope oldfiles<cr>", { desc = "Recent files" })
map("n", "<leader>s", "<cmd>Telescope symbols<cr>", { desc = "Symbols" })
map("n", "<leader>cf", vim.lsp.buf.format, { desc = "Format" })
map("n", "gd", vim.lsp.buf.definition, { desc = "Go to definition" })
map("n", "gr", vim.lsp.buf.references, { desc = "Go to references" })
-- Visual mode -- Indenting
map("v", "<", "<gv") map("v", "<", "<gv")
map("v", ">", ">gv") map("v", ">", ">gv")
-- Mixed modes -- LSP
map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", { desc = "Clear search" }) map("n", "gd", vim.lsp.buf.definition, "Go to definition")
map({ "i", "v", "n", "s" }, "<C-s>", "<cmd>w<cr><esc>", { desc = "Save file" }) map("n", "gr", vim.lsp.buf.references, "Go to references")
map("n", "<leader>cf", vim.lsp.buf.format, "Format")
-- Toggle comment -- Toggle comment
map("n", "<leader>/", "<cmd>lua require('Comment.api').toggle.linewise.current()<cr>", { desc = "Toggle comment" }) map("n", "<C-_>", "<cmd>lua require('Comment.api').toggle.linewise.current()<cr>", "Toggle comment")
map("v", "<leader>/", "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>", { desc = "Toggle comment" }) map("v", "<C-_>", "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>", "Toggle comment")
-- Normal mode
map("n", "<C-b>", "<cmd>NvimTreeToggle<cr>", "Toggle tree")
map("n", "<leader>l", "<cmd>Lazy<cr>", "Lazy")
map("n", "<leader>f", "<cmd>Telescope find_files<cr>", "Find files")
map("n", "<leader>r", "<cmd>Telescope oldfiles<cr>", "Recent files")
map({ "n", "t" }, "<A-i>", "<cmd>lua require('nvterm.terminal').toggle('float')<cr>", "Toggle terminal")

View File

@ -4,22 +4,34 @@ g.loaded_netrw = 1
g.loaded_netrwPlugin = 1 g.loaded_netrwPlugin = 1
local opt = vim.opt local opt = vim.opt
opt.autowrite = false
opt.expandtab = false
opt.shiftwidth = 4
opt.tabstop = 4
opt.softtabstop = 4
opt.autoindent = true opt.autoindent = true
opt.smartindent = true opt.autowrite = false
opt.spell = false opt.clipboard = "unnamedplus"
opt.conceallevel = 0 opt.conceallevel = 0
opt.ignorecase = false
opt.number = true
opt.relativenumber = false
opt.cursorline = true opt.cursorline = true
opt.cursorlineopt = "both" opt.cursorlineopt = "both"
opt.termguicolors = true opt.expandtab = false
opt.signcolumn = "yes" opt.grepformat = "%f:%l:%c:%m"
opt.grepprg = "rg --vimgrep"
opt.ignorecase = false
opt.laststatus = 0 opt.laststatus = 0
opt.showmode = false opt.mouse = "a"
opt.number = true
opt.relativenumber = false
opt.ruler = false opt.ruler = false
opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" }
opt.shiftwidth = 4
opt.showmode = false
opt.signcolumn = "yes"
opt.smartindent = true
opt.softtabstop = 4
opt.spell = false
opt.splitbelow = true
opt.splitright = true
opt.tabstop = 4
opt.termguicolors = true
opt.undofile = true
opt.undolevels = 10000
opt.updatetime = 250
opt.wildmode = "longest:full,full"
opt.wrap = false

View File

@ -1,9 +0,0 @@
return {
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
},
}

View File

@ -0,0 +1,24 @@
return {
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
},
config = function()
local cmp = require("cmp")
cmp.setup({
mapping = {
["<C-space>"] = cmp.mapping.complete(),
["<cr>"] = cmp.mapping.confirm({ select = true }),
},
sources = {
{ name = "nvim_lsp" },
{ name = "buffer" },
{ name = "path" },
},
})
end,
}

View File

@ -1,13 +1,11 @@
return { return {
"numToStr/Comment.nvim", "numToStr/Comment.nvim",
event = "VeryLazy", event = "VeryLazy",
config = true,
opts = { opts = {
mappings = { mappings = {
basic = false, basic = false,
extra = false, extra = false,
}, },
}, },
config = function(_, opts)
require("Comment").setup(opts)
end,
} }

View File

@ -1,7 +1,5 @@
return { return {
"lewis6991/gitsigns.nvim", "lewis6991/gitsigns.nvim",
event = "BufReadPre", event = "BufReadPre",
config = function() config = true,
require("gitsigns").setup()
end,
} }

View File

@ -0,0 +1,18 @@
return {
"folke/noice.nvim",
event = "VeryLazy",
dependencies = {
"MunifTanjim/nui.nvim",
"rcarriga/nvim-notify",
},
opts = {
lsp = {
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true,
},
},
},
config = true,
}

View File

@ -0,0 +1,13 @@
return {
"nvim-telescope/telescope-file-browser.nvim",
enabled = false,
event = "VeryLazy",
dependencies = {
"nvim-telescope/telescope.nvim",
"nvim-lua/plenary.nvim"
},
config = function()
require("telescope").load_extension("file_browser")
vim.keymap.set("n", "<leader>fb", "<cmd>Telescope file_browser<cr>", "File browser")
end,
}

View File

@ -1,6 +1,7 @@
return { return {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
event = "VeryLazy", event = "VeryLazy",
config = true,
dependencies = { dependencies = {
"nvim-lua/plenary.nvim" "nvim-lua/plenary.nvim"
}, },

View File

@ -0,0 +1,5 @@
return {
"NvChad/nvterm",
event = "VeryLazy",
config = true,
}

View File

@ -1,7 +1,14 @@
return { return {
"navarasu/onedark.nvim", "navarasu/onedark.nvim",
event = "VeryLazy", lazy = false,
config = function() priority = 1000,
require('onedark').load() opts = {
style = "dark",
transparent = false,
},
config = function(_, opts)
local theme = require("onedark")
theme.setup(opts)
theme.load()
end, end,
} }

View File

@ -3,7 +3,6 @@ return {
event = "VeryLazy", event = "VeryLazy",
dependencies = { dependencies = {
"nvim-tree/nvim-web-devicons", "nvim-tree/nvim-web-devicons",
"navarasu/onedark.nvim",
}, },
config = function() config = function()
require("nvim-tree").setup({ require("nvim-tree").setup({