Improved neovim config

This commit is contained in:
Eduard Urbach 2023-08-22 16:51:35 +02:00
parent ce110d730e
commit 3d3380b6b6
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
9 changed files with 129 additions and 20 deletions

View File

@ -1,24 +1,26 @@
{
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
"LuaSnip": { "branch": "master", "commit": "c4d6298347f7707e9757351b2ee03d0c00da5c20" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"flash.nvim": { "branch": "main", "commit": "967117690bd677cb7b6a87f0bc0077d2c0be3a27" },
"gitsigns.nvim": { "branch": "main", "commit": "749267aaa863c30d721c9913699c5d94e0c07dd3" },
"lazy.nvim": { "branch": "main", "commit": "dac844ed617dda4f9ec85eb88e9629ad2add5e05" },
"neodev.nvim": { "branch": "main", "commit": "e9bc652e22f9cd1892630bf019db363ac403ee39" },
"neodev.nvim": { "branch": "main", "commit": "02d5988929635fe913daa60f19b909e6a7b23c58" },
"noice.nvim": { "branch": "main", "commit": "894db25ec726d32047799d4d0a982b701bec453b" },
"nui.nvim": { "branch": "main", "commit": "9e3916e784660f55f47daa6f26053ad044db5d6a" },
"nvim-cmp": { "branch": "main", "commit": "51f1e11a89ec701221877532ee1a23557d291dd5" },
"nvim-lspconfig": { "branch": "master", "commit": "67f151e84daddc86cc65f5d935e592f76b9f4496" },
"nvim-lspconfig": { "branch": "master", "commit": "93c6826b16217eaef568ca5c224ea5d0c12bbb82" },
"nvim-notify": { "branch": "master", "commit": "ea9c8ce7a37f2238f934e087c255758659948e0f" },
"nvim-spectre": { "branch": "master", "commit": "eb17a856a6f17e03d8d610cbc00cd9f2f39e3fd7" },
"nvim-tree.lua": { "branch": "master", "commit": "920868dba13466586897a8f40220eca6b2caac41" },
"nvim-treesitter": { "branch": "master", "commit": "7c935d6bd5ecb36e7c6cf6678e1eaa38b85111f3" },
"nvim-treesitter": { "branch": "master", "commit": "2ee71c1a2fa74c10692be10ae420ff0c3a02eb3c" },
"nvim-web-devicons": { "branch": "master", "commit": "cfc8824cc1db316a276b36517f093baccb8e799a" },
"nvterm": { "branch": "main", "commit": "5ae78fb332e92447121d2af58a6313189a7799fb" },
"onedark.nvim": { "branch": "master", "commit": "09b71d84bd2524438e48c0aa5b54d855cc72af32" },
"plenary.nvim": { "branch": "master", "commit": "267282a9ce242bbb0c5dc31445b6d353bed978bb" },
"telescope-project.nvim": { "branch": "master", "commit": "7c64b181dd4e72deddcf6f319e3bf1e95b2a2f30" },
"telescope.nvim": { "branch": "master", "commit": "2d92125620417fbea82ec30303823e3cd69e90e8" }
"telescope.nvim": { "branch": "master", "commit": "2d92125620417fbea82ec30303823e3cd69e90e8" },
"trouble.nvim": { "branch": "main", "commit": "40aad004f53ae1d1ba91bcc5c29d59f07c5f01d3" }
}

View File

@ -15,6 +15,7 @@ on({ "TermOpen", "TermEnter" }, {
on({ "BufNewFile", "BufRead" }, {
pattern = { "*.txt", "*.md" },
callback = function()
vim.lo.wrap = true
vim.opt_local.wrap = true
vim.opt_local.signcolumn = "no"
end,
})

View File

@ -1,28 +1,31 @@
local map = function(mode, lhs, rhs, info)
local function map(mode, lhs, rhs, info)
vim.keymap.set(mode, lhs, rhs, { desc = info })
end
-- Basics
map("n", ";", ":", "Command mode")
map("n", "qq", "<cmd>qa!<cr>", "Quit all")
map("n", "U", "<cmd>redo<cr>", "Redo")
map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", "Clear search")
map({ "i", "n", "s", "v" }, "<C-s>", "<cmd>w<cr><esc>", "Save file")
map("n", "U", "<cmd>redo<cr>", "Redo")
map("n", "<C-q>", "<cmd>bd<cr>", "Delete buffer")
map("n", "<C-n>", "<cmd>enew<cr>", "New File")
map("n", "<C-l>", "^Da", "Rewrite line")
map("i", "<C-l>", "<esc>^Da", "Rewrite line")
map("n", "<C-r>", ":%s/<C-R><C-W>//g<Left><Left>", "Replace word under cursor")
map("n", "<C-q>", "<cmd>qa<cr>", "Quit all")
map({"n", "v"}, "<C-b>", "^", "Beginning of line")
map({ "n", "v" }, "<C-b>", "^", "Beginning of line")
map("i", "<C-b>", "<esc>^i", "Beginning of line")
map({"i", "n", "v"}, "<C-e>", "<end>", "End of line")
map({ "i", "n", "v" }, "<C-e>", "<end>", "End of line")
-- Indenting
map("v", "<", "<gv")
map("v", ">", ">gv")
-- LSP
map("n", "gd", vim.lsp.buf.definition, "Go to definition")
map("n", "gr", vim.lsp.buf.references, "Go to references")
map("n", "<leader>cf", vim.lsp.buf.format, "Format")
map("n", "gr", vim.lsp.buf.references, "Get references")
map("n", "gd", vim.lsp.buf.definition, "Get definition")
map({ "n", "i" }, "<f1>", vim.lsp.buf.hover, "Show information")
map({ "n", "i" }, "<C-f>", vim.lsp.buf.format, "Format")
-- Plugins
map("n", "<leader>t", "<cmd>NvimTreeToggle<cr>", "Toggle tree")
-- Package manager
map("n", "<leader>l", "<cmd>Lazy<cr>", "Lazy")

View File

@ -16,15 +16,15 @@ opt.cursorline = true
opt.cursorlineopt = "both"
opt.expandtab = false
opt.grepformat = "%f:%l:%c:%m"
opt.grepprg = "rg --vimgrep"
opt.grepprg = "rg --grep"
opt.ignorecase = false
opt.laststatus = 0
opt.mouse = "a"
opt.ruler = false
opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" }
opt.shiftwidth = 4
opt.shortmess:append "sI"
opt.shortmess:append "sCFI"
opt.showmode = false
opt.showtabline = 0
opt.smartindent = true
opt.softtabstop = 4
opt.spell = false
@ -40,6 +40,8 @@ opt.wrap = false
-- UI
opt.fillchars = { eob = " ", vert = " " }
opt.laststatus = 0
opt.number = true
opt.relativenumber = false
opt.signcolumn = "yes:1"
opt.statusline = "%{repeat('─',winwidth('.'))}"

View File

@ -1,3 +1,46 @@
local icons = {
Namespace = "󰌗",
Text = "󰉿",
Method = "󰆧",
Function = "󰆧",
Constructor = "",
Field = "󰜢",
Variable = "󰀫",
Class = "󰠱",
Interface = "",
Module = "",
Property = "󰜢",
Unit = "󰑭",
Value = "󰎠",
Enum = "",
Keyword = "󰌋",
Snippet = "",
Color = "󰏘",
File = "󰈚",
Reference = "󰈇",
Folder = "󰉋",
EnumMember = "",
Constant = "󰏿",
Struct = "󰙅",
Event = "",
Operator = "󰆕",
TypeParameter = "󰊄",
Table = "",
Object = "󰅩",
Tag = "",
Array = "[]",
Boolean = "",
Number = "",
Null = "󰟢",
String = "󰉿",
Calendar = "",
Watch = "󰥔",
Package = "",
Copilot = "",
Codeium = "",
TabNine = "",
}
return {
"hrsh7th/nvim-cmp",
event = "InsertEnter",
@ -5,20 +48,52 @@ return {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"L3MON4D3/LuaSnip",
},
config = function()
local cmp = require("cmp")
cmp.setup({
local opts = {
completion = {
completeopt = "menu,menuone,noinsert",
},
formatting = {
fields = { "abbr", "kind", "menu" },
format = function(_, item)
local icon = icons[item.kind] or ""
item.kind = string.format(" %s %s", icon, item.kind)
return item
end,
},
mapping = {
["<C-space>"] = cmp.mapping.complete(),
["<C-up>"] = cmp.mapping.select_prev_item(),
["<C-down>"] = cmp.mapping.select_next_item(),
["<C-e>"] = cmp.mapping.abort(),
["<cr>"] = cmp.mapping.confirm({ select = true }),
},
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
},
})
window = {
completion = {
border = "rounded",
scrollbar = false
},
documentation = {
border = "rounded",
}
},
}
cmp.setup(opts)
end,
}

View File

@ -8,6 +8,7 @@ return {
{"<leader>f", "<cmd>Telescope find_files<cr>", desc = "Find files"},
{"<leader>r", "<cmd>Telescope oldfiles<cr>", desc = "Recent files"},
{"<leader>p", "<cmd>Telescope project<cr>", desc = "Projects"},
{"<leader>b", "<cmd>Telescope buffers<cr>", desc = "Buffers"},
},
config = function()
require("telescope").setup({

View File

@ -6,6 +6,10 @@ return {
style = "dark",
transparent = false,
term_colors = true,
highlights = {
["StatusLine"] = {fg = "$bg3", bg = "Normal"},
["StatusLineNC"] = {fg = "$bg3", bg = "Normal"},
},
},
config = function(_, opts)
local theme = require("onedark")

View File

@ -4,6 +4,9 @@ return {
dependencies = {
"nvim-tree/nvim-web-devicons",
},
keys = {
{ "<leader>e", function() require("nvim-tree.api").tree.toggle() end, desc = "Toggle files" },
},
opts = {
filesystem_watchers = {
enable = true,

View File

@ -0,0 +1,18 @@
return {
"folke/trouble.nvim",
event = "VeryLazy",
keys = {
{ "<leader>x", function() require("trouble").toggle() end, desc = "Show errors" },
},
dependencies = {
"nvim-tree/nvim-web-devicons",
},
opts = {
position = "right",
padding = false,
use_diagnostic_signs = true,
auto_open = true,
auto_close = true,
},
config = true,
}