nvim/init.lua

235 lines
6.1 KiB
Lua

local vim = vim
vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.o.number = true
vim.o.relativenumber = true
vim.o.showmode = true
vim.o.hlsearch = false
vim.o.wrap = true
vim.o.tabstop = 4
vim.g.have_nerd_font = true
vim.o.scrolloff = 10
vim.g.border = "rounded"
vim.o.termguicolors = true
vim.o.cursorline = true
vim.o.swapfile = false
vim.o.mouse = 'a'
vim.o.undofile = true
-- diagnostic config
vim.diagnostic.config({
virtual_text = false,
float = { source = 'always', border = 'rounded' }
})
-- Highlight On Yank
vim.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking (copying) text',
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
callback = function()
vim.hl.on_yank()
end,
})
-- unset space so it can be used as leader
vim.keymap.set("n", " ", "", { silent = true, remap = false })
-- move around windows
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'focus to l window' })
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'focus to r window' })
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'focus to dwn window' })
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'focus to up window' })
-- move lines up and down
vim.keymap.set("n", "<A-j>", ":m .+1<CR>==")
vim.keymap.set("n", "<A-k>", ":m .-2<CR>==")
vim.keymap.set("v", "<A-j>", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "<A-k>", ":m '<-2<CR>gv=gv")
-- toggle nvim tree
vim.keymap.set("n", "<leader>e", ":NvimTreeToggle<CR>")
-- barbar
vim.keymap.set("n", "<leader>x", ":BufferClose<CR>")
-- (I need both options, one for windows, one for linux)
vim.keymap.set("n", "<A-h>", ":BufferPrevious<CR>")
vim.keymap.set("n", "<A-l>", ":BufferNext<CR>")
vim.keymap.set("n", "<A-,>", "<Cmd>BufferPrevious<CR>")
vim.keymap.set("n", "<A-.>", "<Cmd>BufferNext<CR>")
-- diagnostics
vim.keymap.set("n", "<leader>ds", ":lua vim.diagnostic.open_float()<CR>")
vim.keymap.set("n", "<leader>dn", function() vim.diagnostic.jump({ count = 1 }) end)
vim.keymap.set("n", "<leader>dp", function() vim.diagnostic.jump({ count = -1 }) end)
-- VIM PACKS
vim.pack.add({
-- theme
{ src = "https://github.com/neanias/everforest-nvim.git" },
-- lsp
{ src = 'https://github.com/neovim/nvim-lspconfig' },
{ src = 'https://github.com/mason-org/mason.nvim' },
{ src = 'https://github.com/mason-org/mason-lspconfig.nvim' },
{ src = 'https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim' },
-- treesitter
{ src = 'https://github.com/nvim-treesitter/nvim-treesitter', branch = "main", build = ":TSUpdate", lazy = false},
-- bar and icons at the top
{ src = 'https://github.com/nvim-tree/nvim-web-devicons' },
{ src = 'https://github.com/romgrk/barbar.nvim' },
-- file tree
{ src = 'https://github.com/nvim-tree/nvim-tree.lua' },
-- auto save
{ src = 'https://github.com/Pocco81/auto-save.nvim' },
-- completion
{ src = 'https://github.com/saghen/blink.cmp' },
-- lualine
{ src = 'https://github.com/nvim-lualine/lualine.nvim' },
-- surround
{ src = 'https://github.com/echasnovski/nvim-mini/mini.nvim' },
-- telescope
{ src = 'https://github.com/nvim-lua/plenary.nvim' },
{ src = 'https://github.com/nvim-telescope/telescope.nvim' },
})
-- telescope (sadly these configs need to be after vimpack)
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = 'Telescope find files' })
vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope live grep' })
vim.keymap.set('n', '<leader>fb', builtin.buffers, { desc = 'Telescope buffers' })
vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = 'Telescope help tags' })
require('nvim-treesitter.configs').setup {
ensure_installed = {},
modules = {},
sync_install = false,
auto_install = true,
ignore_install = {},
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
}
vim.cmd("colorscheme everforest")
require "barbar".setup()
require "mini.ai".setup()
require "mini.surround".setup()
require "mini.pairs".setup()
require "nvim-tree".setup()
require "auto-save".setup()
require "blink.cmp".setup({
keymap = {
preset = "enter",
["<CR>"] = { "select_and_accept", "fallback" },
},
})
require('lualine').setup {
options = {
icons_enabled = true,
theme = 'everforest',
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
always_show_tabline = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
refresh_time = 16, -- ~60fps
events = {
'WinEnter',
'BufEnter',
'BufWritePost',
'SessionLoadPost',
'FileChangedShellPost', 'VimResized', 'Filetype',
'CursorMoved',
'CursorMovedI',
'ModeChanged',
},
}
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = {'filename'},
lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_y = {'progress'},
lualine_z = {'location'}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_y = {},
lualine_z = {}
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {}
}
require('mason').setup()
require('mason-lspconfig').setup()
require('mason-tool-installer').setup({
ensure_installed = {
"biome",
"djlint",
"emmet-language-server",
"html-lsp",
"lua-language-server",
"lwc-language-server",
"omnisharp",
"prettier",
"prettierd",
"python-lsp-server",
"roslyn",
"ruff",
"selene",
"stylua",
"typescript-language-server",
}
})
vim.lsp.config('lua_ls', {
settings = {
Lua = {
runtime = {
version = 'LuaJIT',
},
diagnostics = {
globals = {
'vim',
'require'
},
},
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
},
telemetry = {
enable = false,
},
},
},
})