From 0b8813831f4bd00741962e04ccc6c4bf42aa8a65 Mon Sep 17 00:00:00 2001 From: lucy Date: Wed, 1 Apr 2026 19:58:56 +0200 Subject: [PATCH] fully set up! --- init.lua | 201 ++++++++++++++++++++++++++++++++++++++++++++ nvim-pack-lock.json | 32 +++++++ 2 files changed, 233 insertions(+) create mode 100644 init.lua create mode 100644 nvim-pack-lock.json diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..20a6807 --- /dev/null +++ b/init.lua @@ -0,0 +1,201 @@ +-- add plugins +vim.pack.add({ + "https://github.com/folke/snacks.nvim", + "https://github.com/nvim-lualine/lualine.nvim", + "https://github.com/RRethy/base16-nvim", + "https://github.com/akinsho/bufferline.nvim", + "https://github.com/nvimdev/lspsaga.nvim", + "https://github.com/neovim/nvim-lspconfig", + "https://github.com/nvim-treesitter/nvim-treesitter", +}) + + +require('lualine').setup() +require('bufferline').setup() +require('snacks').setup({ + notifier = { enabled = true }, + statuscolumn = { enabled = true }, + picker = {} +}) +require('lspsaga').setup({ + symbol_in_winbar = { enable = true }, + lightbulb = { + enable = true, + sign = false, + }, + hover = { + max_width = 0.6, + open_link = "gx", + open_browser = "!google-chrome", + } +}) +-- general options +local opt = vim.opt +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" +opt.number = true +opt.relativenumber = true + +opt.cursorline = true +opt.termguicolors = true +opt.winborder = "rounded" +opt.signcolumn = "yes" +vim.lsp.inlay_hint.enable = true +opt.tabstop = 8 +vim.opt.expandtab = true +vim.g.tinted_background_transparent = 1 + +opt.shiftwidth = 8 +vim.diagnostic.config({ + virtual_text = { + spacing = 4, + source = true, + }, +}) +-- setup lualine +require('lualine').setup({ + options = { + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "diagnostics" }, + lualine_c = { "filename", "branch", "navic" }, + lualine_x = { "lsp_status", "filetype" }, + lualine_y = { "progress" }, + lualine_z = { "location" }, + }, +}) + + +-- keymaps +local map = vim.keymap.set + +map("n", "ff", function() + Snacks.picker.files() +end) +map("n", "lg", function() + Snacks.picker.grep() +end) + +-- lsp keybinds +map("n", "K", " Lspsaga hover_doc") +map("n", "go", " Lspsaga goto_definition") +map("n", "gr", " Lspsaga finder") +map("n", "qf", " Lspsaga code_action") +map("n", "", function() + vim.lsp.buf.format() +end) +-- bufferline keybinds +map("n", "", " BufferLineGoToBuffer 1 ") +map("n", "", " BufferLineGoToBuffer 2 ") +map("n", "", " BufferLineGoToBuffer 3 ") +map("n", "", " BufferLineGoToBuffer 4 ") +map("n", "", " BufferLineGoToBuffer 5 ") +map("n", "", " BufferLineGoToBuffer 6 ") +map("n", "", " BufferLineGoToBuffer 7 ") +map("n", "", " BufferLineGoToBuffer 8 ") +map("n", "", " BufferLineGoToBuffer 9 ") +map("n", "", " BufferLineGoToBuffer last ") +map("n", "w", " bdelete! ") + +-- util keybinds +map("n", "t", " terminal ") +map("n", "", "Lspsaga term_toggle") +map("t", "", "") +map("i", "", vim.lsp.completion.get, { desc = "trigger autocompletion" }) +-- lsp setup +vim.lsp.config('*', { + on_attach = function(client, bufnr) + vim.lsp.completion.enable(true, client.id, bufnr, { + autotrigger = true, + convert = function(item) + return { abbr = item.label:gsub("%b()", "") } + end, + }) + vim.keymap.set("i", "", vim.lsp.completion.get, { desc = "trigger autocompletion" }) + end +}) +vim.lsp.enable('lua_ls') +vim.lsp.enable('qmlls') +vim.lsp.enable('clangd') + +vim.o.complete = ".,o" -- use buffer and omnifunc +vim.o.completeopt = "fuzzy,menuone,noselect" -- add 'popup' for docs (sometimes) +vim.o.autocomplete = false +vim.o.pumheight = 7 + + +vim.api.nvim_create_autocmd("LspAttach", { + callback = function(ev) + vim.lsp.completion.enable(true, ev.data.client_id, ev.buf, { + -- Optional formating of items + convert = function(item) + -- Remove leading misc chars for abbr name, + -- and cap field to 25 chars + --local abbr = item.label + --abbr = abbr:match("[%w_.]+.*") or abbr + --abbr = #abbr > 25 and abbr:sub(1, 24) .. "…" or abbr + -- + -- Remove return value + --local menu = "" + + -- Only show abbr name, remove leading misc chars (bullets etc.), + -- and cap field to 15 chars + local abbr = item.label + abbr = abbr:gsub("%b()", ""):gsub("%b{}", "") + abbr = abbr:match("[%w_.]+.*") or abbr + abbr = #abbr > 15 and abbr:sub(1, 14) .. "…" or abbr + + -- Cap return value field to 15 chars + local menu = item.detail or "" + menu = #menu > 15 and menu:sub(1, 14) .. "…" or menu + + return { abbr = abbr, menu = menu } + end, + }) + end, +}) + + + + + +-- tinty function +local default_theme = "base16-oceanicnext" + +local function get_tinty_theme() + local theme_name = vim.fn.system("cat ~/.local/share/tinted-theming/tinty/current_scheme") + + if vim.v.shell_error ~= 0 then + return default_theme + else + return vim.trim(theme_name) + end +end + +local function handle_focus_gained() + local new_theme_name = get_tinty_theme() + local current_theme_name = vim.g.colors_name + + if current_theme_name ~= new_theme_name then + vim.cmd("colorscheme " .. new_theme_name) + require("lualine").setup() + end + require("lualine").setup() +end + +local function main() + vim.o.termguicolors = true + vim.g.tinted_colorspace = 256 + local current_theme_name = get_tinty_theme() + + vim.cmd("colorscheme " .. current_theme_name) + + vim.api.nvim_create_autocmd("FocusGained", { + callback = handle_focus_gained, + }) +end + +main() diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json new file mode 100644 index 0000000..c2b10e0 --- /dev/null +++ b/nvim-pack-lock.json @@ -0,0 +1,32 @@ +{ + "plugins": { + "base16-nvim": { + "rev": "190397833e53fdfd5cf400c5baaf1a4e533158e5", + "src": "https://github.com/RRethy/base16-nvim" + }, + "bufferline.nvim": { + "rev": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3", + "src": "https://github.com/akinsho/bufferline.nvim" + }, + "lspsaga.nvim": { + "rev": "562d9724e3869ffd1801c572dd149cc9f8d0cc36", + "src": "https://github.com/nvimdev/lspsaga.nvim" + }, + "lualine.nvim": { + "rev": "47f91c416daef12db467145e16bed5bbfe00add8", + "src": "https://github.com/nvim-lualine/lualine.nvim" + }, + "nvim-lspconfig": { + "rev": "8e2084bf5e40c79c1f42210a6ef96a0a4793a763", + "src": "https://github.com/neovim/nvim-lspconfig" + }, + "nvim-treesitter": { + "rev": "c82bf96f0a773d85304feeb695e1e23b2207ac35", + "src": "https://github.com/nvim-treesitter/nvim-treesitter" + }, + "snacks.nvim": { + "rev": "ad9ede6a9cddf16cedbd31b8932d6dcdee9b716e", + "src": "https://github.com/folke/snacks.nvim" + } + } +}