From 060443394279760974e6daca8408514507081ab4 Mon Sep 17 00:00:00 2001 From: Alexander Muszynski Date: Tue, 18 Feb 2025 09:32:47 -0500 Subject: [PATCH] chore: fix warnings --- init.lua | 185 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 159 insertions(+), 26 deletions(-) diff --git a/init.lua b/init.lua index db024f7..e03c10d 100644 --- a/init.lua +++ b/init.lua @@ -164,7 +164,7 @@ vim.keymap.set('n', '', 'nohlsearch') -- Diagnostic keymaps vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) -vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) +vim.keymap.set('n', 'z', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) vim.keymap.set('n', ';', ':', { desc = 'CMD enter command mode' }) @@ -209,6 +209,7 @@ vim.api.nvim_create_autocmd('TextYankPost', { -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' +-- replace with vim.uv.fs_stat eventually if not vim.loop.fs_stat(lazypath) then local lazyrepo = 'https://github.com/folke/lazy.nvim.git' vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } @@ -279,22 +280,22 @@ require('lazy').setup({ 'folke/which-key.nvim', event = 'VimEnter', -- Sets the loading event to 'VimEnter' config = function() -- This is the function that runs, AFTER loading - require('which-key').setup() + local wk = require 'which-key' -- Document existing key chains - require('which-key').register { - ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, - ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, - ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, - ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, - ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, - ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, - ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, - ['g'] = { name = '[G]it Search', _ = 'which_key_ignore' }, + wk.add { + { 'c', desc = '[C]ode' }, + { 'd', desc = '[D]ocument' }, + { 'r', desc = '[R]ename' }, + { 's', desc = '[S]earch' }, + { 'w', desc = '[W]orkspace' }, + { 't', desc = '[T]oggle' }, + { 'h', desc = 'Git [H]unk' }, + { 'g', desc = '[G]it Search' }, } -- visual mode - require('which-key').register({ - ['h'] = { 'Git [H]unk' }, + wk.add({ + { 'h', 'Git [H]unk' }, }, { mode = 'v' }) end, }, @@ -573,17 +574,17 @@ require('lazy').setup({ -- - settings (table): Override the default settings passed when initializing the server. -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { - -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, + clangd = {}, + gopls = {}, + pyright = {}, + rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- -- Some languages (like typescript) have entire language plugins that can be useful: -- https://github.com/pmizio/typescript-tools.nvim -- -- But for many setups, the LSP (`tsserver`) will work just fine - -- tsserver = {}, + ts_ls = {}, -- lua_ls = { @@ -596,7 +597,7 @@ require('lazy').setup({ callSnippet = 'Replace', }, -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings - -- diagnostics = { disable = { 'missing-fields' } }, + diagnostics = { disable = { 'missing-fields' } }, }, }, }, @@ -633,9 +634,12 @@ require('lazy').setup({ -- json 'json-lsp', }) + require('mason-tool-installer').setup { ensure_installed = ensure_installed } require('mason-lspconfig').setup { + ensure_installed = servers, + automatic_installation = true, handlers = { function(server_name) local server = servers[server_name] or {} @@ -683,7 +687,7 @@ require('lazy').setup({ -- -- You can use a sub-list to tell conform to run *until* a formatter -- is found. - markdown = { 'markdownlint', 'marksman' }, + markdown = { 'markdownlint' }, javascript = { 'prettierd', 'prettier' }, typescript = { 'prettierd', 'prettier', stop_after_first = true, lsp_fallback = false }, typescriptreact = { 'prettierd', 'prettier' }, @@ -711,12 +715,14 @@ require('lazy').setup({ -- `friendly-snippets` contains a variety of premade snippets. -- See the README about individual language/framework/plugin snippets: -- https://github.com/rafamadriz/friendly-snippets - -- { - -- 'rafamadriz/friendly-snippets', - -- config = function() - -- require('luasnip.loaders.from_vscode').lazy_load() - -- end, - -- }, + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').load { + exclude = { 'javascript' }, + } + end, + }, }, }, 'saadparwaiz1/cmp_luasnip', @@ -934,6 +940,133 @@ require('lazy').setup({ -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` { import = 'custom.plugins' }, }, { + root = vim.fn.stdpath 'data' .. '/lazy', + defaults = {}, + spec = nil, + debug = false, + local_spec = false, + lockfile = vim.fn.stdpath 'config' .. '/lazy-lock.json', + concurrency = jit.os:find 'Windows' and (vim.uv.available_parallelism() * 2) or nil, + headless = { + -- show the output from process commands like git + process = true, + -- show log messages + log = true, + -- show task start/end + task = true, + -- use ansi colors + colors = true, + }, + diff = { + -- diff command can be one of: + -- * browser: opens the github compare view. Note that this is always mapped to as well, + -- so you can have a different command for diff + -- * git: will run git diff and open a buffer with filetype git + -- * terminal_git: will open a pseudo terminal with git diff + -- * diffview.nvim: will open Diffview to show the diff + cmd = 'git', + }, + checker = { + -- automatically check for plugin updates + enabled = false, + concurrency = nil, ---@type number? set to 1 to check for updates very slowly + notify = true, -- get a notification when new updates are found + frequency = 3600, -- check for updates every hour + check_pinned = false, -- check for pinned packages that can't be updated + }, + change_detection = { + -- automatically check for config file changes and reload the ui + enabled = true, + notify = true, -- get a notification when changes are found + }, + performance = { + cache = { + enabled = true, + }, + reset_packpath = true, -- reset the package path to improve startup time + rtp = { + reset = true, -- reset the runtime path to $VIMRUNTIME and your config directory + ---@type string[] + paths = {}, -- add any custom paths here that you want to includes in the rtp + ---@type string[] list any plugins you want to disable here + disabled_plugins = { + -- "gzip", + -- "matchit", + -- "matchparen", + -- "netrwPlugin", + -- "tarPlugin", + -- "tohtml", + -- "tutor", + -- "zipPlugin", + }, + }, + }, + -- lazy can generate helptags from the headings in markdown readme files, + -- so :help works even for plugins that don't have vim docs. + -- when the readme opens with :help it will be correctly displayed as markdown + readme = { + enabled = true, + root = vim.fn.stdpath 'state' .. '/lazy/readme', + files = { 'README.md', 'lua/**/README.md' }, + -- only generate markdown helptags for plugins that don't have docs + skip_if_doc_exists = true, + }, + state = vim.fn.stdpath 'state' .. '/lazy/state.json', -- state info for checker and other things + -- Enable profiling of lazy.nvim. This will add some overhead, + -- so only enable this when you are debugging lazy.nvim + profiling = { + -- Enables extra stats on the debug tab related to the loader cache. + -- Additionally gathers stats about all package.loaders + loader = false, + -- Track each new require in the Lazy profiling tab + require = false, + }, + git = { + log = { '-8' }, + timeout = 120, + filter = true, + throttle = { + enabled = false, + rate = 2, + duration = 5 * 1000, -- in ms + }, + cooldown = 0, + }, + pkg = { + enabled = true, + cache = vim.fn.stdpath 'state' .. '/lazy/pkg-cache.lua', + -- the first package source that is found for a plugin will be used. + sources = { + 'lazy', + 'rockspec', -- will only be used when rocks.enabled is true + 'packspec', + }, + }, + rocks = { + enabled = false, + root = vim.fn.stdpath 'data' .. '/lazy-rocks', + server = 'https://nvim-neorocks.github.io/rocks-binaries/', + -- use hererocks to install luarocks? + -- set to `nil` to use hererocks when luarocks is not found + -- set to `true` to always use hererocks + -- set to `false` to always use luarocks + hererocks = nil, + }, + dev = { + -- Directory where you store your local plugin projects. If a function is used, + -- the plugin directory (e.g. `~/projects/plugin-name`) must be returned. + ---@type string | fun(plugin: LazyPlugin): string + path = '~/projects', + ---@type string[] plugins that match these patterns will use your local versions instead of being fetched from GitHub + patterns = {}, -- For example {"folke"} + fallback = false, -- Fallback to git when local plugin doesn't exist + }, + install = { + -- install missing plugins on startup. This doesn't increase startup time. + missing = true, + -- try to load one of these colorschemes when starting an installation during startup + colorscheme = { 'habamax' }, + }, ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the -- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table