diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua index 618a6b3..984f1d1 100644 --- a/.config/nvim/after/plugin/lsp.lua +++ b/.config/nvim/after/plugin/lsp.lua @@ -1,26 +1,46 @@ local lsp_zero = require('lsp-zero') -lsp_zero.on_attach(function(client, bufnr) - -- see :help lsp-zero-keybindings - -- to learn the available actions +-- Attach keybindings on LSP connection +local lsp_attach = function(client, bufnr) lsp_zero.default_keymaps({ buffer = bufnr }) -end) +end -lsp_zero.set_sign_icons({ - error = '✘', - warn = '▲', - hint = '⚑', - info = '»' +lsp_zero.extend_lspconfig({ + lsp_attach = lsp_attach, + capabilities = require('cmp_nvim_lsp').default_capabilities() +}) + +-- Configure diagnostic signs natively for Neovim v0.11+ +vim.diagnostic.config({ + signs = { + text = { + [vim.diagnostic.severity.ERROR] = '✘', + [vim.diagnostic.severity.WARN] = '▲', + [vim.diagnostic.severity.HINT] = '⚑', + [vim.diagnostic.severity.INFO] = '»' + } + } }) --- to learn how to use mason.nvim --- read this: https://github.com/VonHeikemen/lsp-zero.nvim/blob/v3.x/doc/md/guide/integrate-with-mason-nvim.md require('mason').setup({}) require('mason-lspconfig').setup({ ensure_installed = {'lua_ls', 'ts_ls', 'eslint', 'gopls', 'rust_analyzer'}, handlers = {function(server_name) - require('lspconfig')[server_name].setup({}) + -- Map legacy server names to their modern equivalents + if server_name == 'tsserver' then + server_name = 'ts_ls' + end + + -- Verify the server configuration is accessible to prevent indexing errors + local has_config, _ = pcall(function() + return require('lspconfig')[server_name] + end) + if has_config then + require('lspconfig')[server_name].setup({}) + else + vim.notify("LSP configuration not accessible for: " .. server_name, vim.log.levels.WARN) + end end} }) diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index fb025f6..dabd75f 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,6 +1,7 @@ { "LuaSnip": { "branch": "master", "commit": "a62e1083a3cfe8b6b206e7d3d33a51091df25357" }, "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, + "flexoki": { "branch": "main", "commit": "c3e2251e813d29d885a7cbbe9808a7af234d845d" }, "lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" }, "lsp-zero.nvim": { "branch": "v3.x", "commit": "77550f2f6cbf0959ef1583d845661af075f3442b" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "0a3b42c3e503df87aef6d6513e13148381495c3a" }, diff --git a/.config/nvim/lua/cole/init.lua b/.config/nvim/lua/cole/init.lua index bad9a3d..04140f8 100644 --- a/.config/nvim/lua/cole/init.lua +++ b/.config/nvim/lua/cole/init.lua @@ -1,5 +1,4 @@ require("cole.remap") +require("cole.lazy") require("cole.set") require("cole.filetype") -require("cole.lazy") - diff --git a/.config/nvim/lua/cole/lazy.lua b/.config/nvim/lua/cole/lazy.lua index 0cacf58..a3c40cc 100644 --- a/.config/nvim/lua/cole/lazy.lua +++ b/.config/nvim/lua/cole/lazy.lua @@ -1,16 +1,20 @@ -require("lazy").setup({ -- Fuzzy finder -{ +require("lazy").setup({{ + "bluz71/vim-moonfly-colors", + name = "moonfly", + lazy = false, + priority = 1000 +}, { 'nvim-telescope/telescope.nvim', tag = '0.1.5', dependencies = {'nvim-lua/plenary.nvim'} -}, -- syntax highlighting +}, -- Fuzzy finder { 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate' -}, -- LSP support +}, -- syntax highlighting { 'VonHeikemen/lsp-zero.nvim', - branch = 'v3.x', + branch = 'v4.x', dependencies = {{'williamboman/mason.nvim'}, {'williamboman/mason-lspconfig.nvim'}, {'neovim/nvim-lspconfig'}, - {'hrsh7th/nvim-cmp'}, {'hrsh7th/cmp-nvim-lsp'}, {'L3MON4D3/LuaSnip'}} + {'hrsh7th/nvim-cmp'}, {'hrsh7th/cmp-nvim-lsp'}, {'L3MON4D3/LuaSnip'}} -- LSP support }}) diff --git a/.config/nvim/lua/cole/set.lua b/.config/nvim/lua/cole/set.lua index 4d82f35..78633c8 100644 --- a/.config/nvim/lua/cole/set.lua +++ b/.config/nvim/lua/cole/set.lua @@ -17,7 +17,7 @@ vim.opt.incsearch = true vim.opt.scrolloff = 8 -- Always 8 lines above -- Color scheme -vim.cmd.colorscheme("habamax") +vim.cmd.colorscheme("moonfly") -- Diff: Muted Red on Crimson vim.api.nvim_set_hl(0, "DiffAdd", { @@ -45,32 +45,41 @@ vim.api.nvim_create_autocmd("VimEnter", { return end - -- Calculate the longest display-width line in the left (current) buffer. - local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false) - local max_len = 0 - for _, line in ipairs(lines) do - local len = vim.fn.strdisplaywidth(line) - if len > max_len then - max_len = len + -- Defer execution to unblock the initial UI render + vim.schedule(function() + -- Limit the line check to the first 2000 lines to prevent long startup times on large files + local max_lines_to_check = 2000 + local line_count = vim.api.nvim_buf_line_count(0) + local limit = math.min(line_count, max_lines_to_check) + local lines = vim.api.nvim_buf_get_lines(0, 0, limit, false) + local max_len = 0 + + for _, line in ipairs(lines) do + local len = vim.api.nvim_strwidth(line) + if len > max_len then + max_len = len + end end - end - -- Account for gutter columns (line numbers, sign column, fold column). - local gutter = 0 - if vim.wo.number or vim.wo.relativenumber then - gutter = gutter + vim.wo.numberwidth - end - if vim.wo.signcolumn ~= "no" then - gutter = gutter + 2 - end - gutter = gutter + vim.wo.foldcolumn + -- Account for gutter columns (line numbers, sign column, fold column). + local gutter = 0 + if vim.wo.number or vim.wo.relativenumber then + gutter = gutter + vim.wo.numberwidth + end + if vim.wo.signcolumn ~= "no" then + gutter = gutter + 2 + end - local desired = max_len + gutter + 1 -- +1 for the right edge padding + local fold_col = tonumber(vim.wo.foldcolumn) or 0 + gutter = gutter + fold_col - -- Cap at exactly half the terminal width. - local half = math.floor(vim.o.columns / 2) - local width = math.min(desired, half) + local desired = max_len + gutter + 1 -- +1 for the right edge padding - vim.api.nvim_win_set_width(0, width) + -- Cap at exactly half the terminal width. + local half = math.floor(vim.o.columns / 2) + local width = math.min(desired, half) + + vim.api.nvim_win_set_width(0, width) + end) end }) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..496ee2c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file