vim.pack.add({ { src = 'https://github.com/ibhagwan/fzf-lua' }, { src = "https://github.com/saghen/blink.lib" }, { src = "https://github.com/Saghen/blink.cmp" }, { src = 'https://github.com/neovim/nvim-lspconfig' }, { src = 'https://github.com/romus204/tree-sitter-manager.nvim' }, { src = 'https://github.com/lukas-reineke/indent-blankline.nvim' }, { src = 'https://github.com/xiyaowong/transparent.nvim' }, { src = 'https://github.com/nvim-lua/plenary.nvim' }, { src = 'https://github.com/NeogitOrg/neogit' }, }) -- ------------------------------------------------------------ -- TREE SITTER MANAGER -- ------------------------------------------------------------ require("tree-sitter-manager").setup() -- ------------------------------------------------------------ -- FUZZY FINDERS -- ------------------------------------------------------------ require("fzf-lua").setup({}) map("n", "", "FzfLua files") map("n", "", "FzfLua buffers") map("n", "", "FzfLua diagnostics_workspace") map("n", "", "FzfLua live_grep") map("n", "", "FzfLua grep_curbuf") -- ------------------------------------------------------------ -- BLINK COMPLETION -- ------------------------------------------------------------ require("blink.cmp").setup({ keymap = { [""] = { "select_next", "fallback", }, [""] = { "select_prev", "fallback", }, [""] = { "select_next", "fallback", }, [""] = { "select_prev", "fallback", }, [""] = { "accept", "fallback", }, [""] = { "show", "show_documentation", "hide_documentation", }, [""] = { "hide", "fallback", }, }, appearance = { nerd_font_variant = "normal", }, completion = { menu = { border = "single", }, documentation = { auto_show = true, auto_show_delay_ms = 200, window = { border = "single", }, }, ghost_text = { enabled = true, }, }, signature = { enabled = true, }, sources = { default = { "lsp", "path", "buffer", }, }, fuzzy = { implementation = "lua", }, }) -- ------------------------------------------------------------ -- LSP -- ------------------------------------------------------------ local capabilities = require("blink.cmp").get_lsp_capabilities() vim.lsp.config("gopls", { capabilities = capabilities, }) vim.lsp.config("ols", { capabilities = capabilities, }) vim.lsp.enable({ "gopls", "ols", }) map("n", "gd", vim.lsp.buf.definition) map("n", "gD", vim.lsp.buf.declaration) map("n", "gi", vim.lsp.buf.implementation) map("n", "gr", vim.lsp.buf.references) map("n", "K", vim.lsp.buf.hover) map("i", "", vim.lsp.buf.signature_help) map("n", "rn", vim.lsp.buf.rename) map("n", "ca", vim.lsp.buf.code_action) map("n", "[d", vim.diagnostic.goto_prev) map("n", "]d", vim.diagnostic.goto_next) map("n", "d", vim.diagnostic.open_float) map("n", "q", vim.diagnostic.setloclist) -- ------------------------------------------------------------ -- INDENT LINES -- ------------------------------------------------------------ require("ibl").setup({ indent = { char = "│", }, scope = { show_start = false, show_end = false, }, }) -- ------------------------------------------------------------ -- NEOGIT -- ------------------------------------------------------------ require("neogit").setup({ kind = "vsplit", -- matches your terminal split habit graph_style = "unicode", commit_editor = { kind = "vsplit" }, commit_select_view = { kind = "vsplit" }, log_view = { kind = "vsplit" }, rebase_editor = { kind = "vsplit" }, reflog_view = { kind = "vsplit" }, merge_editor = { kind = "vsplit" }, tag_editor = { kind = "vsplit" }, preview_buffer = { kind = "split" }, popup = { kind = "split" }, signs = { hunk = { "", "" }, item = { ">", "v" }, section = { ">", "v" }, }, integrations = { telescope = false, diffview = false, }, disable_insert_on_commit = "auto", }) -- ------------------------------------------------------------ -- TERMINAL SYSTEM -- ------------------------------------------------------------ local term_buf = nil local function open_term_split() vim.cmd("botright vsplit") local win = vim.api.nvim_get_current_win() if term_buf and vim.api.nvim_buf_is_valid(term_buf) then vim.api.nvim_win_set_buf(win, term_buf) else vim.cmd("terminal") term_buf = vim.api.nvim_get_current_buf() end vim.api.nvim_win_set_width(win, math.floor(vim.o.columns * 0.37)) vim.cmd("startinsert") end local function toggle_term() for _, win in ipairs(vim.api.nvim_list_wins()) do if vim.api.nvim_win_get_buf(win) == term_buf then vim.api.nvim_win_close(win, false) return end end open_term_split() end local function open_term_fullscreen() if term_buf and vim.api.nvim_buf_is_valid(term_buf) then vim.api.nvim_set_current_buf(term_buf) else vim.cmd("terminal") term_buf = vim.api.nvim_get_current_buf() end vim.cmd("startinsert") end local function prev_non_term_buf() local current = vim.api.nvim_get_current_buf() local buffers = vim.fn.getbufinfo({ buflisted = 1 }) local candidates = {} for _, buffer in ipairs(buffers) do if buffer.bufnr ~= current and vim.bo[buffer.bufnr].buftype ~= "terminal" then table.insert(candidates, buffer) end end if #candidates == 0 then print("No previous non-terminal buffer") return end table.sort(candidates, function(a, b) return a.lastused > b.lastused end) vim.api.nvim_set_current_buf(candidates[1].bufnr) end function send(command) local terminal_visible = false for _, win in ipairs(vim.api.nvim_list_wins()) do if term_buf and vim.api.nvim_win_get_buf(win) == term_buf then terminal_visible = true break end end if not terminal_visible then open_term_split() end local job = vim.b[term_buf].terminal_job_id if job then vim.api.nvim_chan_send(job, command .. "\n") end end map("n", "", toggle_term, { desc = "Toggle terminal split", }) map("n", "", open_term_fullscreen, { desc = "Open terminal fullscreen", }) map("t", "", toggle_term, { desc = "Toggle terminal split", }) map("t", "", prev_non_term_buf, { desc = "Return to previous buffer", }) -- ------------------------------------------------------------ -- BUILD SYSTEM -- ------------------------------------------------------------ local function build(args) if vim.fn.filereadable("build.sh") == 0 then vim.notify("No build.sh found in current directory.", vim.log.levels.WARN) return end vim.cmd("wall") local command = "./build.sh" if #args > 0 then command = command .. " " .. table.concat(args, " ") end send("clear && " .. command) end vim.api.nvim_create_user_command( "Build", function(opts) build(opts.fargs) end, { nargs = "*", desc = "Run project build.sh", } ) map("n", "", function() build({}) end, { desc = "Build project", }) map("t", "", function() build({}) end, { desc = "Build project", }) -- ------------------------------------------------------------ -- Setup Alacritty colorscheme from Neovim -- ------------------------------------------------------------ local function set_alacritty_colorscheme(name) -- The name of the Alacritty colorscheme placed in the theme directory -- MUST be the same as the name of the colorscheme in Neovim local config_dir = vim.fn.expand("$XDG_CONFIG_HOME/alacritty") local config = config_dir .. "/alacritty.toml" local source = config_dir .. "/themes/" .. name .. ".toml" local dest = config_dir .. "/colorscheme.toml" local cmd = "ln -sf " .. source .. " " .. dest .. " && touch " .. config vim.fn.jobstart(cmd, { on_exit = function(_, code, _) if code ~= 0 then vim.notify("Failed to set Alacritty color scheme", vim.log.levels.ERROR) end end, }) end vim.api.nvim_create_autocmd("ColorScheme", { group = vim.api.nvim_create_augroup("config_alacritty_colorscheme", { clear = true }), callback = function(args) set_alacritty_colorscheme(args.match) end, })