diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 6d35a46..0616ece 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -1,4 +1,3 @@ -vim.cmd.colorscheme("vim") vim.g.mapleader = " " vim.keymap.set("n", "", "") vim.keymap.set("n", "", "") @@ -19,160 +18,177 @@ vim.keymap.set("v", "K", ":m '<-2gv=gv") vim.keymap.set({ 'n', 'v', 'x' }, 'd', '"+d') vim.keymap.set({ 'n', 'v', 'x' }, 'y', '"+y') -vim.o.relativenumber = true -vim.o.number = true -vim.o.shiftwidth = 8 -vim.o.tabstop = 8 -vim.o.expandtab = false -vim.o.wrap = false -vim.o.winborder = "rounded" +vim.cmd("set nocompatible") -- force 'nocompatible', like modern Vim +vim.cmd("syntax off") +vim.o.background = "dark" vim.o.clipboard = "unnamedplus" +vim.o.cmdheight = 1 +vim.o.expandtab = false +vim.o.hlsearch = false +vim.o.ignorecase = false +vim.o.incsearch = false +vim.o.laststatus = 1 +vim.o.number = true +vim.o.relativenumber = true +vim.o.ruler = true +vim.o.shiftwidth = 8 +vim.o.showcmd = true +vim.o.showmode = true +vim.o.showtabline = 0 +vim.o.smartcase = false +vim.o.statusline = "" vim.o.swapfile = false +vim.o.tabstop = 8 +vim.o.termguicolors = false +vim.o.wildmenu = false +vim.o.winborder = "rounded" +vim.o.wrap = false vim.opt.path:append("**") vim.keymap.set("i", "me::", function() - return vim.fn.strftime("Author: vx_clutch \nDate: %B %d, %Y\nLicense: BSD-3-Clause") + return vim.fn.strftime( + "Author: vx_clutch \nDate: %B %d, %Y\nLicense: BSD-3-Clause") end, { expr = true }) local augroup = vim.api.nvim_create_augroup("vxclutch", {}) vim.api.nvim_create_autocmd("BufReadPost", { - group = augroup, - callback = function() - local mark = vim.api.nvim_buf_get_mark(0, '"') - local lcount = vim.api.nvim_buf_line_count(0) - if mark[1] > 0 and mark[1] <= lcount then - pcall(vim.api.nvim_win_set_cursor, 0, mark) - end - end, + group = augroup, + callback = function() + local mark = vim.api.nvim_buf_get_mark(0, '"') + local lcount = vim.api.nvim_buf_line_count(0) + if mark[1] > 0 and mark[1] <= lcount then + pcall(vim.api.nvim_win_set_cursor, 0, mark) + end + end, }) vim.api.nvim_create_autocmd("TermOpen", { - group = augroup, - callback = function() - vim.opt_local.number = false - vim.opt_local.relativenumber = false - vim.opt_local.signcolumn = "no" - end, + group = augroup, + callback = function() + vim.opt_local.number = false + vim.opt_local.relativenumber = false + vim.opt_local.signcolumn = "no" + end, }) vim.api.nvim_create_autocmd("BufWritePre", { - group = augroup, - callback = function() - local dir = vim.fn.expand(':p:h') - if vim.fn.isdirectory(dir) == 0 then - vim.fn.mkdir(dir, 'p') - end - end, + group = augroup, + callback = function() + local dir = vim.fn.expand(':p:h') + if vim.fn.isdirectory(dir) == 0 then + vim.fn.mkdir(dir, 'p') + end + end, }) local undodir = vim.fn.expand("~/.vim/undodir") if vim.fn.isdirectory(undodir) == 0 then - vim.fn.mkdir(undodir, "p") + vim.fn.mkdir(undodir, "p") end local terminal_state = { - buf = nil, - win = nil, - is_open = false + buf = nil, + win = nil, + is_open = false } local function FloatingTerminal() - if terminal_state.is_open and vim.api.nvim_win_is_valid(terminal_state.win) then - vim.api.nvim_win_close(terminal_state.win, false) - terminal_state.is_open = false - return - end + if terminal_state.is_open and vim.api.nvim_win_is_valid(terminal_state.win) then + vim.api.nvim_win_close(terminal_state.win, false) + terminal_state.is_open = false + return + end - if not terminal_state.buf or not vim.api.nvim_buf_is_valid(terminal_state.buf) then - terminal_state.buf = vim.api.nvim_create_buf(false, true) + if not terminal_state.buf or not vim.api.nvim_buf_is_valid(terminal_state.buf) then + terminal_state.buf = vim.api.nvim_create_buf(false, true) - vim.api.nvim_buf_set_option(terminal_state.buf, 'bufhidden', 'hide') - end + vim.api.nvim_buf_set_option(terminal_state.buf, 'bufhidden', 'hide') + end - local width = math.floor(vim.o.columns * 0.8) - local height = math.floor(vim.o.lines * 0.8) - local row = math.floor((vim.o.lines - height) / 2) - local col = math.floor((vim.o.columns - width) / 2) + local width = math.floor(vim.o.columns * 0.8) + local height = math.floor(vim.o.lines * 0.8) + local row = math.floor((vim.o.lines - height) / 2) + local col = math.floor((vim.o.columns - width) / 2) - terminal_state.win = vim.api.nvim_open_win(terminal_state.buf, true, { - relative = 'editor', - width = width, - height = height, - row = row, - col = col, - style = 'minimal', - border = 'rounded', - }) + terminal_state.win = vim.api.nvim_open_win(terminal_state.buf, true, { + relative = 'editor', + width = width, + height = height, + row = row, + col = col, + style = 'minimal', + border = 'rounded', + }) - vim.api.nvim_win_set_option(terminal_state.win, 'winblend', 0) + vim.api.nvim_win_set_option(terminal_state.win, 'winblend', 0) - vim.api.nvim_win_set_option(terminal_state.win, 'winhighlight', - 'Normal:FloatingTermNormal,FloatBorder:FloatingTermBorder') + vim.api.nvim_win_set_option(terminal_state.win, 'winhighlight', + 'Normal:FloatingTermNormal,FloatBorder:FloatingTermBorder') - vim.api.nvim_set_hl(0, "FloatingTermNormal", { bg = "none" }) - vim.api.nvim_set_hl(0, "FloatingTermBorder", { bg = "none", }) + vim.api.nvim_set_hl(0, "FloatingTermNormal", { bg = "none" }) + vim.api.nvim_set_hl(0, "FloatingTermBorder", { bg = "none", }) - local has_terminal = false - local lines = vim.api.nvim_buf_get_lines(terminal_state.buf, 0, -1, false) - for _, line in ipairs(lines) do - if line ~= "" then - has_terminal = true - break - end - end + local has_terminal = false + local lines = vim.api.nvim_buf_get_lines(terminal_state.buf, 0, -1, false) + for _, line in ipairs(lines) do + if line ~= "" then + has_terminal = true + break + end + end - if not has_terminal then - vim.fn.termopen(os.getenv("SHELL")) - end + if not has_terminal then + vim.fn.termopen(os.getenv("SHELL")) + end - terminal_state.is_open = true - vim.cmd("startinsert") + terminal_state.is_open = true + vim.cmd("startinsert") - vim.api.nvim_create_autocmd("BufLeave", { - buffer = terminal_state.buf, - callback = function() - if terminal_state.is_open and vim.api.nvim_win_is_valid(terminal_state.win) then - vim.api.nvim_win_close(terminal_state.win, false) - terminal_state.is_open = false - end - end, - once = true - }) + vim.api.nvim_create_autocmd("BufLeave", { + buffer = terminal_state.buf, + callback = function() + if terminal_state.is_open and vim.api.nvim_win_is_valid(terminal_state.win) then + vim.api.nvim_win_close(terminal_state.win, false) + terminal_state.is_open = false + end + end, + once = true + }) end local function CloseFloatingTerminal() - if terminal_state.is_open and vim.api.nvim_win_is_valid(terminal_state.win) then - vim.api.nvim_win_close(terminal_state.win, false) - terminal_state.is_open = false - end + if terminal_state.is_open and vim.api.nvim_win_is_valid(terminal_state.win) then + vim.api.nvim_win_close(terminal_state.win, false) + terminal_state.is_open = false + end end vim.keymap.set("n", "t", FloatingTerminal, { noremap = true, silent = true }) vim.keymap.set("t", "", function() - if terminal_state.is_open then - vim.api.nvim_win_close(terminal_state.win, false) - terminal_state.is_open = false - end + if terminal_state.is_open then + vim.api.nvim_win_close(terminal_state.win, false) + terminal_state.is_open = false + end end, { noremap = true, silent = true }) vim.pack.add({ - { src = "https://github.com/neovim/nvim-lspconfig" }, + { src = "https://github.com/neovim/nvim-lspconfig" }, }) local lspconfig = require("lspconfig") local servers = { "lua_ls", "clangd" } for _, server in ipairs(servers) do - lspconfig[server].setup({}) + lspconfig[server].setup({}) end vim.diagnostic.config({ - virtual_text = true, - underline = true, + virtual_text = true, + underline = true, })