------------------------------------------------------------------- -- Settings ------------------------------------------------------------------- vim.opt.winborder = "rounded" vim.opt.hlsearch = false vim.opt.tabstop = 4 vim.opt.cursorcolumn = false vim.opt.ignorecase = true vim.opt.shiftwidth = 4 vim.opt.smartindent = true vim.opt.number = true vim.opt.relativenumber = true vim.opt.termguicolors = true vim.opt.undofile = true vim.opt.signcolumn = "yes" vim.g.netrw_banner = 0 -- gets rid of the annoying banner for netrw vim.g.netrw_browse_split = 4 -- open in prior window vim.g.netrw_altv = 1 -- change from left splitting to right splitting vim.g.netrw_liststyle = 3 -- tree style view in netrw ------------------------------------------------------------------- -- Autocommands ------------------------------------------------------------------- -- -- show cursor line only in active window -- local cursorLineGrp = vim.api.nvim_create_augroup("CursorLine", { clear = true }) -- vim.api.nvim_create_autocmd( -- { "InsertLeave", "WinEnter" }, -- { pattern = "*", command = "set cursorline", group = cursorLineGrp } -- ) -- vim.api.nvim_create_autocmd( -- { "InsertEnter", "WinLeave" }, -- { pattern = "*", command = "set nocursorline", group = cursorLineGrp } -- ) -- vim.api.nvim_create_autocmd( -- { "InsertLeave", "FocusGained" }, -- { pattern = "*", command = "set cursorline", group = cursorLineGrp } -- ) -- vim.api.nvim_create_autocmd( -- { "InsertEnter", "FocusLost" }, -- { pattern = "*", command = "set nocursorline", group = cursorLineGrp } -- ) ------------------------------------------------------------------- -- Plugin installation ------------------------------------------------------------------- vim.pack.add({ { src = "https://git.cmtec.se/cm/nightly_cm.nvim.git" }, { src = "https://github.com/mrjones2014/smart-splits.nvim" }, { src = "https://github.com/nvim-lua/plenary.nvim" }, { src = "https://github.com/kdheepak/lazygit.nvim" }, { src = "https://github.com/echasnovski/mini.icons" }, { src = "https://github.com/echasnovski/mini.statusline" }, { src = "https://github.com/echasnovski/mini.pick" }, { src = 'https://github.com/neovim/nvim-lspconfig' }, { src = 'https://github.com/lewis6991/gitsigns.nvim' }, { src = 'https://github.com/MunifTanjim/nui.nvim' }, { src = 'https://github.com/folke/noice.nvim' }, }) ------------------------------------------------------------------- -- Plugin config ------------------------------------------------------------------- -- colorscheme vim.cmd.colorscheme("nightly_cm") require "noice".setup() require "mini.pick".setup() require "mini.statusline".setup() require "gitsigns".setup({ signs = { add = { text = "▎" }, change = { text = "▎" }, delete = { text = "▎" }, topdelete = { text = "▎" }, changedelete = { text = "▎" }, untracked = { text = "▎" }, }, preview_config = { -- Options passed to nvim_open_win border = "solid", style = "minimal", relative = "cursor", row = 0, col = 1, }, }) ------------------------------------------------------------------- -- LSP config ------------------------------------------------------------------- vim.lsp.enable({ "lua_ls", "rust_analyzer", "bashls", "pyright", "marksman", "clangd", "yamlls" }) -- prevent the built-in vim.lsp.completion autotrigger from selecting the first item vim.opt.completeopt = { "menuone", "popup", "noselect" } vim.api.nvim_create_autocmd("LspAttach", { callback = function(ev) local client = vim.lsp.get_client_by_id(ev.data.client_id) if client ~= nil and client:supports_method("textDocument/completion") then vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true }) end end, }) vim.diagnostic.config({ severity_sort = true, float = { border = "rounded", source = "if_many" }, underline = { severity = vim.diagnostic.severity.ERROR }, signs = { text = { [vim.diagnostic.severity.ERROR] = "󰅚 ", [vim.diagnostic.severity.WARN] = "󰀪 ", [vim.diagnostic.severity.INFO] = "󰋽 ", [vim.diagnostic.severity.HINT] = "󰌶 ", }, } or {}, virtual_text = { source = "if_many", spacing = 2, format = function(diagnostic) local diagnostic_message = { [vim.diagnostic.severity.ERROR] = diagnostic.message, [vim.diagnostic.severity.WARN] = diagnostic.message, [vim.diagnostic.severity.INFO] = diagnostic.message, [vim.diagnostic.severity.HINT] = diagnostic.message, } return diagnostic_message[diagnostic.severity] end, }, }) ------------------------------------------------------------------- -- Keybindings ------------------------------------------------------------------- local map = vim.keymap.set vim.g.mapleader = " " -- QoL bindings map('i', 'jj', '', { noremap = true, silent = true }) map('n', 'u', ':update :source', { noremap = true, silent = true }) map('n', 'w', ':write', { noremap = true, silent = true }) map('n', 'q', ':quit', { noremap = true, silent = true }) map('n', 'v', ':vsplit', { noremap = true, silent = true }) -- Git map('n', 'g', ':LazyGitCurrentFile', { noremap = true, silent = true }) -- File browser map('n', 'e', ':25Lex', { noremap = true, silent = true }) map('n', 'f', ":Pick files", { noremap = true, silent = true }) map('n', 'h', ":Pick help", { noremap = true, silent = true }) -- LSP map('n', 'lf', vim.lsp.buf.format, { noremap = true, silent = true }) -- Global Copy/Paste map({ 'n', 'v' }, 'y', '"+y', { noremap = true, silent = true }) map({ 'n', 'v' }, 'd', '"+d', { noremap = true, silent = true }) map({ 'n', 'v' }, 'c', '1z=', { noremap = true, silent = true }) -- Smart splits to support TMUX map({ "n", "t" }, "", require("smart-splits").resize_left, { desc = "Resize left" }) map({ "n", "t" }, "", require("smart-splits").resize_down, { desc = "Resize down" }) map({ "n", "t" }, "", require("smart-splits").resize_up, { desc = "Resize up" }) map({ "n", "t" }, "", require("smart-splits").resize_right, { desc = "Resize right" }) map({ "n", "t" }, "", require("smart-splits").move_cursor_left, { desc = "Move cursor left" }) map({ "n", "t" }, "", require("smart-splits").move_cursor_down, { desc = "Move cursor down" }) map({ "n", "t" }, "", require("smart-splits").move_cursor_up, { desc = "Move cursor up" }) map({ "n", "t" }, "", require("smart-splits").move_cursor_right, { desc = "Move cursor right" }) map("n", "h", require("smart-splits").swap_buf_left, { desc = "Swap buffer left" }) map("n", "j", require("smart-splits").swap_buf_down, { desc = "Swap buffer down" }) map("n", "k", require("smart-splits").swap_buf_up, { desc = "Swap buffer up" }) map("n", "l", require("smart-splits").swap_buf_right, { desc = "Swap buffer right" })