new neovim config

This commit is contained in:
Václav Uruba 2025-01-12 23:47:31 +01:00
parent c0c91062e3
commit ff34437d23
Signed by: uruba
GPG Key ID: 9D8E987C4B2E1E9C
35 changed files with 581 additions and 92 deletions

View File

@ -1,4 +1,7 @@
require('core/theme')
require('core/basic-vars')
require('core/keymap')
require('lazy-init')
require('core/basic-vars')
require('core/options')
require('core/theme')

View File

@ -0,0 +1,36 @@
{
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
"alpha-nvim": { "branch": "main", "commit": "de72250e054e5e691b9736ee30db72c65d560771" },
"auto-session": { "branch": "main", "commit": "021b64ed7d4ac68a37be3ad28d8e1cba5bec582c" },
"barbar.nvim": { "branch": "master", "commit": "a26bae6c51899db530de19ce3c2f4307e37a869e" },
"bufferline.nvim": { "branch": "main", "commit": "5726c4e291224181903e960119a11e20ac677a0a" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
"dressing.nvim": { "branch": "master", "commit": "3a45525bb182730fe462325c99395529308f431e" },
"friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" },
"gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" },
"hererocks": { "branch": "master", "commit": "c9c5444dea1e07e005484014a8231aa667be30b6" },
"indent-blankline.nvim": { "branch": "master", "commit": "259357fa4097e232730341fa60988087d189193a" },
"lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" },
"lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" },
"lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"mini.nvim": { "branch": "main", "commit": "f968becf44b05d8c54d4fa95c9ca699df4de363b" },
"nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" },
"nvim-cmp": { "branch": "main", "commit": "b555203ce4bd7ff6192e759af3362f9d217e8c89" },
"nvim-tree.lua": { "branch": "master", "commit": "68fc4c20f5803444277022c681785c5edd11916d" },
"nvim-treesitter": { "branch": "master", "commit": "57713d079c3c2afcc31f3e0650bf8594a2a296ba" },
"nvim-ts-autotag": { "branch": "main", "commit": "1cca23c9da708047922d3895a71032bc0449c52d" },
"nvim-web-devicons": { "branch": "master", "commit": "5740b7382429d20b6ed0bbdb0694185af9507d44" },
"onedark.nvim": { "branch": "master", "commit": "67a74c275d1116d575ab25485d1bfa6b2a9c38a6" },
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
"rest.nvim": { "branch": "main", "commit": "545509268d5e928d72d64764c21ef65c77e90edf" },
"tagbar": { "branch": "master", "commit": "8de7694c0aeda253073098bbc9fb890b2902ddb8" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" },
"telescope.nvim": { "branch": "master", "commit": "2eca9ba22002184ac05eddbe47a7fe2d5a384dfc" },
"vim-css-color": { "branch": "master", "commit": "14fd934cdd9ca1ac0e53511094e612eb9bace373" },
"vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" },
"which-key.nvim": { "branch": "main", "commit": "8ab96b38a2530eacba5be717f52e04601eb59326" }
}

View File

@ -1,14 +1,36 @@
vim.o.tabstop = 4
vim.o.softtabstop = 4
vim.o.shiftwidth = 4
vim.o.smarttab = true
-- Editor
vim.o.cursorline = true
vim.o.expandtab = true
vim.o.mouse = a
-- Mouse
vim.o.mouse = 'a'
-- Line numbers
vim.o.number = true
vim.o.relativenumber = true
vim.o.undofile = true
-- Tabs and indentation
vim.o.shiftwidth = 4
vim.o.smarttab = true
vim.o.softtabstop = 4
vim.o.tabstop = 4
vim.o.wrap = false
-- Modes
vim.o.showmode = false
-- Undo
vim.o.undodir = vim.fn.expand('~/.vim/undo')
vim.o.undofile = true
vim.o.undolevels = 1024
vim.g.mapleader = " "
-- Search
vim.o.ignorecase = true
vim.o.smartcase = true
-- GUI
vim.o.termguicolors = true
-- Clipboard
--vim.o.clipboard = 'unnamedplus'

View File

@ -0,0 +1,15 @@
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- Insert mode tweaks
vim.keymap.set('i', 'jk', '<ESC>', { desc = 'Exit insert mode' })
-- Window management
vim.keymap.set('n', '<leader>sv', '<C-w>v', { desc = 'Split window vertically' })
vim.keymap.set('n', '<leader>sh', '<C-w>h', { desc = 'Split window horizonatally' })
vim.keymap.set('n', '<leader>se', '<C-w>=', { desc = 'Make splits equal size' })
vim.keymap.set('n', '<leader>sx', '<cmd>close<cr>', { desc = 'Close current split' })
-- Buffer management
vim.keymap.set('n', '<leader>bn', '<cmd>bn<cr>', { desc = 'Next buffer' })
vim.keymap.set('n', '<leader>bp', '<cmd>bp<cr>', { desc = 'Prev buffer' })

View File

@ -0,0 +1 @@
vim.cmd("let g:netrw_liststyle = 3")

View File

@ -13,7 +13,7 @@ end
-- OneDark styles: dark, darker, cool, deep, warm, warmer, light
require('onedark').setup {
style = 'darker',
style = 'deep',
colors = { fg = '#b2bbcc' }, --default: #a0a8b7
}
require('onedark').load()

View File

@ -5,18 +5,29 @@
-- Plugin manager: lazy.nvim
-- url: https://github.com/folke/lazy.nvim
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,
})
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)
require("lazy").setup("lazy-plugins")
require('lazy').setup('lazy-plugins', {
checker = {
enabled = true,
notify = false,
},
change_detection = {
notify = false,
},
})

View File

@ -1,8 +0,0 @@
-- Alpha (start screen/dashboard)
return {
"goolord/alpha-nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function ()
require"alpha".setup(require"alpha.themes.startify".config)
end,
}

View File

@ -0,0 +1,4 @@
-- Plenary
return {
"williamboman/mason.nvim",
}

View File

@ -1,6 +1,6 @@
-- CSS color
return {
"ap/vim-css-color",
'ap/vim-css-color',
}

View File

@ -0,0 +1,23 @@
return {
'rmagatti/auto-session',
event = 'VeryLazy',
config = function()
local auto_session = require('auto-session')
auto_session.setup({
auto_restore_enabled = false,
})
end,
keys = {
{
'<leader>wr',
'<cmd>SessionRestore<cr>',
desc = 'Session restore',
},
{
'<leader>ws',
'<cmd>SessionSave<cr>',
desc = 'Session save',
}
},
}

View File

@ -0,0 +1,4 @@
-- Diffview
return {
'sindrets/diffview.nvim',
}

View File

@ -0,0 +1,12 @@
-- Indent blankline
return {
'lukas-reineke/indent-blankline.nvim',
event = {
'BufReadPre',
'BufNewFile',
},
main = 'ibl',
opts = {
indent = { char = '' },
},
}

View File

@ -0,0 +1,53 @@
return {
"rest-nvim/rest.nvim",
dependencies = { { "nvim-lua/plenary.nvim" } },
event = "BufEnter *.http",
config = function()
require("rest-nvim").setup({
-- Open request results in a horizontal split
result_split_horizontal = false,
-- Keep the http file buffer above|left when split horizontal|vertical
result_split_in_place = false,
-- stay in current windows (.http file) or change to results window (default)
stay_in_current_window_after_split = false,
-- Skip SSL verification, useful for unknown certificates
skip_ssl_verification = false,
-- Encode URL before making request
encode_url = true,
-- Highlight request on run
highlight = {
enabled = true,
timeout = 150,
},
result = {
-- toggle showing URL, HTTP info, headers at top the of result window
show_url = true,
-- show the generated curl command in case you want to launch
-- the same request via the terminal (can be verbose)
show_curl_command = false,
show_http_info = true,
show_headers = true,
-- table of curl `--write-out` variables or false if disabled
-- for more granular control see Statistics Spec
show_statistics = false,
-- executables or functions for formatting response body [optional]
-- set them to false if you want to disable them
formatters = {
json = "jq",
html = function(body)
return vim.fn.system({"tidy", "-i", "-q", "-"}, body)
end
},
},
-- Jump to request line on run
jump_to_request = false,
env_file = '.env',
-- for telescope select
env_pattern = "\\.env$",
env_edit_command = "tabedit",
custom_dynamic_variables = {},
yank_dry_run = true,
search_back = true,
})
end
}

View File

@ -1,4 +0,0 @@
-- Indent blankline
return {
"lukas-reineke/indent-blankline.nvim",
}

View File

@ -1,5 +0,0 @@
-- Lastplace
return {
"farmergreg/vim-lastplace",
}

View File

@ -0,0 +1,63 @@
return {
'hrsh7th/nvim-cmp',
event = 'InsertEnter',
dependencies = {
'hrsh7th/cmp-buffer', -- source for text in buffer
'hrsh7th/cmp-path', -- source for file system paths
{
'L3MON4D3/LuaSnip',
-- follow latest release.
version = 'v2.*', -- Replace <CurrentMajor> by the latest released major (first number of latest release)
-- install jsregexp (optional!).
build = 'make install_jsregexp',
},
'saadparwaiz1/cmp_luasnip', -- for autocompletion
'rafamadriz/friendly-snippets', -- useful snippets
'onsails/lspkind.nvim', -- vs-code like pictograms
},
config = function()
local cmp = require('cmp')
local luasnip = require('luasnip')
local lspkind = require('lspkind')
-- loads vscode style snippets from installed plugins (e.g. friendly-snippets)
require('luasnip.loaders.from_vscode').lazy_load()
cmp.setup({
completion = {
completeopt = 'menu,menuone,preview,noselect',
},
snippet = { -- configure how nvim-cmp interacts with snippet engine
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
['<C-k>'] = cmp.mapping.select_prev_item(), -- previous suggestion
['<C-j>'] = cmp.mapping.select_next_item(), -- next suggestion
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(), -- show completion suggestions
['<C-e>'] = cmp.mapping.abort(), -- close completion window
['<CR>'] = cmp.mapping.confirm({ select = false }),
}),
-- sources for autocompletion
sources = cmp.config.sources({
{ name = 'nvim_lsp'},
{ name = 'luasnip' }, -- snippets
{ name = 'buffer' }, -- text within current buffer
{ name = 'path' }, -- file system paths
}),
-- configure lspkind for vs-code like pictograms in completion menu
formatting = {
format = lspkind.cmp_format({
maxwidth = 50,
ellipsis_char = '...',
}),
},
})
end,
}

View File

@ -0,0 +1,48 @@
return {
'nvim-treesitter/nvim-treesitter',
event = {
'BufReadPre',
'BufNewFile',
},
build = ':TSUpdate',
dependencies = {
'windwp/nvim-ts-autotag',
},
config = function()
local treesitter = require('nvim-treesitter.configs')
treesitter.setup({
highlight = {
enable = true,
},
indent = {
enable = true,
},
autotag = {
enable = true,
},
ensure_installed = {
'json',
'javascript',
'yaml',
'html',
'css',
'lua',
'vim',
'dockerfile',
'gitignore',
'markdown',
'bash',
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = '<C-space>',
node_incremental = '<C-space>',
scope_incremental = false,
node_decremental = '<bs>',
},
},
})
end,
}

View File

@ -1,48 +0,0 @@
function git_root()
return string.gsub(vim.fn.system("git rev-parse --show-toplevel"), "\n", "")
end
function get_opts()
local opts = {}
local root = git_root()
if vim.v.shell_error == 0 then
opts.cwd = root
end
return opts
end
-- Telescope
return {
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
keys = {
{
"<leader>fp",
function()
require("telescope.builtin").find_files(get_opts())
end,
},
{
"<leader>ff",
function()
require('telescope.builtin').live_grep(get_opts())
end,
},
{
"<leader>fb",
function()
require('telescope.builtin').buffers(get_opts())
end,
},
{
"<leader>fh",
function()
require('telescope.builtin').help_tags(get_opts())
end,
},
},
}

View File

@ -1,4 +1,4 @@
-- Onedark theme
return {
"navarasu/onedark.nvim",
'navarasu/onedark.nvim',
}

View File

@ -0,0 +1,38 @@
-- Alpha (start screen/dashboard)
return {
"goolord/alpha-nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
event = "VimEnter",
config = function()
local alpha = require("alpha")
local dashboard = require("alpha.themes.dashboard")
-- Set header
dashboard.section.header.val = {
" ",
" ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ",
" ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ",
" ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ",
" ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ",
" ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ",
" ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ",
" ",
}
-- Set menu
dashboard.section.buttons.val = {
dashboard.button("e", " > New File", "<cmd>ene<CR>"),
dashboard.button("SPC ee", " > Toggle file explorer", "<cmd>NvimTreeToggle<CR>"),
dashboard.button("SPC ff", "󰱼 > Find File", "<cmd>Telescope find_files<CR>"),
dashboard.button("SPC fs", " > Find Word", "<cmd>Telescope live_grep<CR>"),
dashboard.button("SPC wr", "󰁯 > Restore Session For Current Directory", "<cmd>SessionRestore<CR>"),
dashboard.button("q", " > Quit NVIM", "<cmd>qa<CR>"),
}
-- Send config to alpha
alpha.setup(dashboard.opts)
-- Disable folding on alpha buffer
vim.cmd([[autocmd FileType alpha setlocal nofoldenable]])
end,
}

View File

@ -1,6 +1,7 @@
-- Barbar (tabline bar)
return {
"romgrk/barbar.nvim",
enabled = false,
dependencies = {
"lewis6991/gitsigns.nvim",
"nvim-tree/nvim-web-devicons",

View File

@ -0,0 +1,13 @@
return {
'akinsho/bufferline.nvim',
dependencies = {
'nvim-tree/nvim-web-devicons',
},
version = '*',
opts = {
options = {
-- mode = 'tabs',
-- separator_style = 'slant',
},
},
}

View File

@ -0,0 +1,4 @@
return {
'stevearc/dressing.nvim',
event = 'VeryLazy',
}

View File

@ -0,0 +1,76 @@
return {
'nvim-lualine/lualine.nvim',
dependencies = {
'nvim-tree/nvim-web-devicons',
},
config = function()
local lualine = require('lualine')
local lazy_status = require('lazy.status') -- to configure lazy pending updates count
local colors = {
blue = '#65D1FF',
green = '#3EFFDC',
violet = '#FF61EF',
yellow = '#FFDA7B',
red = '#FF4A4A',
fg = '#c3ccdc',
bg = '#112638',
inactive_bg = '#2c3043',
}
local my_lualine_theme = {
normal = {
a = { bg = colors.blue, fg = colors.bg, gui = 'bold' },
b = { bg = colors.bg, fg = colors.fg },
c = { bg = colors.bg, fg = colors.fg },
},
insert = {
a = { bg = colors.green, fg = colors.bg, gui = 'bold' },
b = { bg = colors.bg, fg = colors.fg },
c = { bg = colors.bg, fg = colors.fg },
},
visual = {
a = { bg = colors.violet, fg = colors.bg, gui = 'bold' },
b = { bg = colors.bg, fg = colors.fg },
c = { bg = colors.bg, fg = colors.fg },
},
command = {
a = { bg = colors.yellow, fg = colors.bg, gui = 'bold' },
b = { bg = colors.bg, fg = colors.fg },
c = { bg = colors.bg, fg = colors.fg },
},
replace = {
a = { bg = colors.red, fg = colors.bg, gui = 'bold' },
b = { bg = colors.bg, fg = colors.fg },
c = { bg = colors.bg, fg = colors.fg },
},
inactive = {
a = { bg = colors.inactive_bg, fg = colors.semilightgray, gui = 'bold' },
b = { bg = colors.inactive_bg, fg = colors.semilightgray },
c = { bg = colors.inactive_bg, fg = colors.semilightgray },
},
}
-- configure lualine with modified theme
lualine.setup({
options = {
theme = my_lualine_theme,
disabled_filetypes = {
statusline = { 'NvimTree' },
},
},
sections = {
lualine_x = {
{
lazy_status.updates,
cond = lazy_status.has_updates,
color = { fg = '#ff9e64' },
},
{ 'encoding' },
{ 'fileformat' },
{ 'filetype' },
},
},
})
end,
}

View File

@ -0,0 +1,7 @@
-- Mini.nvim
return {
'echasnovski/mini.nvim',
config = function()
require('mini.icons').setup()
end
}

View File

@ -0,0 +1,46 @@
return {
"nvim-tree/nvim-tree.lua",
dependencies = "nvim-tree/nvim-web-devicons",
config = function()
local nvimtree = require('nvim-tree')
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
nvimtree.setup({
view = {
width = 35,
relativenumber = true,
},
-- change folder arrow icons
renderer = {
indent_markers = {
enable = true,
},
icons = {
glyphs = {
folder = {
arrow_closed = "", -- arrow when folder is closed
arrow_open = "", -- arrow when folder is open
},
},
},
},
git = {
ignore = false,
},
})
vim.keymap.set('n', '<leader>ef', '<cmd>NvimTreeFindFile<CR>', { desc = 'Move to file in file explorer' })
vim.keymap.set('n', '<leader>ec', '<cmd>NvimTreeCollapse<CR>', { desc = 'Collapse file explorer' })
vim.keymap.set('n', '<leader>er', '<cmd>NvimTreeRefresh<CR>', { desc = 'Refresh file explorer' })
end,
keys = {
{
'<leader>ee',
function()
require('nvim-tree.api').tree.toggle()
end,
desc = 'Toggle file explorer',
},
}
}

View File

@ -1,4 +1,5 @@
-- Tagbar
return {
"preservim/tagbar",
enabled = false,
}

View File

@ -0,0 +1,60 @@
-- Telescope
return {
'nvim-telescope/telescope.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' },
'nvim-tree/nvim-web-devicons',
},
config = function(_, opts)
local telescope = require('telescope')
local actions = require('telescope.actions')
telescope.setup({
defaults = {
path_display = { 'smart' },
mappings = {
i = {
['<C-k>'] = actions.move_selection_previous, -- move to prev result
['<C-j>'] = actions.move_selection_next, -- move to next result
['<C-q>'] = actions.send_selected_to_qflist + actions.open_qflist,
['<C-d>'] = actions.delete_buffer,
}
}
}
})
telescope.load_extension('fzf')
end,
keys = {
{
'<leader>ff',
'<cmd>Telescope find_files<cr>',
desc = 'Find files',
},
{
'<leader>fg',
'<cmd>Telescope live_grep<cr>',
desc = 'Live grep',
},
{
'<leader>fb',
'<cmd>Telescope buffers<cr>',
desc = 'Buffers'
},
{
'<leader>fh',
'<cmd>Telescope help_tags<cr>',
desc = 'Help tags',
},
{
'<leader>fr',
'<cmd>Telescope oldfiles<cr>`',
desc = 'Recent files',
},
{
'<leader>fs',
'<cmd>Telescope grep_string<cr>',
desc = 'Find string',
},
},
}

View File

@ -0,0 +1,17 @@
return {
'folke/which-key.nvim',
event = 'VeryLazy',
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 500
end,
config = function()
local wk = require("which-key")
wk.register({
{ "<leader>e", group = "NeoTree" },
{ "<leader>f", group = "Telescope" },
{ "<leader>s", group = "splits" },
})
end,
opts = { },
}

View File

@ -1,4 +0,0 @@
-- Sensible defaults
return {
"tpope/vim-sensible",
}