aboutsummaryrefslogtreecommitdiffstats
path: root/.config
diff options
context:
space:
mode:
Diffstat (limited to '.config')
-rw-r--r--.config/nvim/lua/simenandre/plugins/plugins.lua242
1 files changed, 115 insertions, 127 deletions
diff --git a/.config/nvim/lua/simenandre/plugins/plugins.lua b/.config/nvim/lua/simenandre/plugins/plugins.lua
index ba353c4..969b96e 100644
--- a/.config/nvim/lua/simenandre/plugins/plugins.lua
+++ b/.config/nvim/lua/simenandre/plugins/plugins.lua
@@ -1,6 +1,5 @@
return {
"tpope/vim-sleuth", -- Detect tabstop and shiftwidth automatically
- { "numToStr/Comment.nvim", opts = {} },
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
"lewis6991/gitsigns.nvim",
opts = {
@@ -13,46 +12,59 @@ return {
},
},
},
- {
- "christoomey/vim-tmux-navigator",
- cmd = {
- "TmuxNavigateLeft",
- "TmuxNavigateDown",
- "TmuxNavigateUp",
- "TmuxNavigateRight",
- "TmuxNavigatePrevious",
- },
- keys = {
- { "<c-h>", "<cmd><C-U>TmuxNavigateLeft<cr>" },
- { "<c-j>", "<cmd><C-U>TmuxNavigateDown<cr>" },
- { "<c-k>", "<cmd><C-U>TmuxNavigateUp<cr>" },
- { "<c-l>", "<cmd><C-U>TmuxNavigateRight<cr>" },
- { "<c-\\>", "<cmd><C-U>TmuxNavigatePrevious<cr>" },
- },
- },
{ -- Useful plugin to show you pending keybinds.
"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()
+ opts = {
+ icons = {
+ -- set icon mappings to true if you have a Nerd Font
+ mappings = vim.g.have_nerd_font,
+ -- If you are using a Nerd Font: set icons.keys to an empty table which will use the
+ -- default whick-key.nvim defined Nerd Font icons, otherwise define a string table
+ keys = vim.g.have_nerd_font and {} or {
+ Up = "<Up> ",
+ Down = "<Down> ",
+ Left = "<Left> ",
+ Right = "<Right> ",
+ C = "<C-…> ",
+ M = "<M-…> ",
+ D = "<D-…> ",
+ S = "<S-…> ",
+ CR = "<CR> ",
+ Esc = "<Esc> ",
+ ScrollWheelDown = "<ScrollWheelDown> ",
+ ScrollWheelUp = "<ScrollWheelUp> ",
+ NL = "<NL> ",
+ BS = "<BS> ",
+ Space = "<Space> ",
+ Tab = "<Tab> ",
+ F1 = "<F1>",
+ F2 = "<F2>",
+ F3 = "<F3>",
+ F4 = "<F4>",
+ F5 = "<F5>",
+ F6 = "<F6>",
+ F7 = "<F7>",
+ F8 = "<F8>",
+ F9 = "<F9>",
+ F10 = "<F10>",
+ F11 = "<F11>",
+ F12 = "<F12>",
+ },
+ },
-- Document existing key chains
- require("which-key").register({
- ["<leader>c"] = { name = "[C]ode", _ = "which_key_ignore" },
- ["<leader>d"] = { name = "[D]ocument", _ = "which_key_ignore" },
- ["<leader>r"] = { name = "[R]ename", _ = "which_key_ignore" },
- ["<leader>s"] = { name = "[S]earch", _ = "which_key_ignore" },
- ["<leader>w"] = { name = "[W]orkspace", _ = "which_key_ignore" },
- ["<leader>t"] = { name = "[T]oggle", _ = "which_key_ignore" },
- ["<leader>h"] = { name = "Git [H]unk", _ = "which_key_ignore" },
- })
- -- visual mode
- require("which-key").register({
- ["<leader>h"] = { "Git [H]unk" },
- }, { mode = "v" })
- end,
+ spec = {
+ { "<leader>c", group = "[C]ode", mode = { "n", "x" } },
+ { "<leader>d", group = "[D]ocument" },
+ { "<leader>r", group = "[R]ename" },
+ { "<leader>s", group = "[S]earch" },
+ { "<leader>w", group = "[W]orkspace" },
+ { "<leader>t", group = "[T]oggle" },
+ { "<leader>h", group = "Git [H]unk", mode = { "n", "v" } },
+ },
+ },
},
-
{ -- Fuzzy Finder (files, lsp, etc)
"nvim-telescope/telescope.nvim",
event = "VimEnter",
@@ -137,6 +149,7 @@ return {
vim.keymap.set("n", "<leader>/", function()
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({
+ winblend = 10,
previewer = false,
}))
end, { desc = "[/] Fuzzily search in current buffer" })
@@ -156,8 +169,21 @@ return {
end, { desc = "[S]earch [N]eovim files" })
end,
},
-
- { -- LSP Configuration & Plugins
+ {
+ -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
+ -- used for completion, annotations and signatures of Neovim apis
+ "folke/lazydev.nvim",
+ ft = "lua",
+ opts = {
+ library = {
+ -- Load luvit types when the `vim.uv` word is found
+ { path = "luvit-meta/library", words = { "vim%.uv" } },
+ },
+ },
+ },
+ { "Bilal2453/luvit-meta", lazy = true },
+ {
+ -- Main LSP Configuration
"neovim/nvim-lspconfig",
dependencies = {
-- Automatically install LSPs and related tools to stdpath for Neovim
@@ -169,9 +195,8 @@ return {
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
{ "j-hui/fidget.nvim", opts = {} },
- -- `neodev` configures Lua LSP for your Neovim config, runtime and plugins
- -- used for completion, annotations and signatures of Neovim apis
- { "folke/neodev.nvim", opts = {} },
+ -- Allows extra capabilities provided by nvim-cmp
+ "hrsh7th/cmp-nvim-lsp",
},
config = function()
-- Brief aside: **What is LSP?**
@@ -211,8 +236,9 @@ return {
--
-- In this case, we create a function that lets us more easily define mappings specific
-- for LSP related items. It sets the mode, buffer and description for us each time.
- local map = function(keys, func, desc)
- vim.keymap.set("n", keys, func, { buffer = event.buf, desc = "lsp: " .. desc })
+ local map = function(keys, func, desc, mode)
+ mode = mode or "n"
+ vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc })
end
-- Jump to the definition of the word under your cursor.
@@ -246,11 +272,7 @@ return {
-- Execute a code action, usually your cursor needs to be on top of an error
-- or a suggestion from your LSP for this to activate.
- map("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction")
-
- -- Opens a popup that displays documentation about the word under your cursor
- -- See `:help K` for why this keymap.
- map("K", vim.lsp.buf.hover, "Hover Documentation")
+ map("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" })
-- WARN: This is not Goto Definition, this is Goto Declaration.
-- For example, in C this would take you to the header.
@@ -262,7 +284,7 @@ return {
--
-- When you move your cursor, the highlights will be cleared (the second autocommand).
local client = vim.lsp.get_client_by_id(event.data.client_id)
- if client and client.server_capabilities.documentHighlightProvider then
+ if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then
local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false })
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
buffer = event.buf,
@@ -285,18 +307,27 @@ return {
})
end
- -- The following autocommand is used to enable inlay hints in your
+ -- The following code creates a keymap to toggle inlay hints in your
-- code, if the language server you are using supports them
--
-- This may be unwanted, since they displace some of your code
- if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then
+ if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
map("<leader>th", function()
- vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
+ vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf }))
end, "[T]oggle Inlay [H]ints")
end
end,
})
+ -- Change diagnostic symbols in the sign column (gutter)
+ -- if vim.g.have_nerd_font then
+ -- local signs = { Error = '', Warn = '', Hint = '', Info = '' }
+ -- for type, icon in pairs(signs) do
+ -- local hl = 'DiagnosticSign' .. type
+ -- vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
+ -- end
+ -- end
+
-- LSP servers and clients are able to communicate to each other what features they support.
-- By default, Neovim doesn't support everything that is in the LSP specification.
-- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
@@ -315,7 +346,7 @@ return {
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
local servers = {
-- clangd = {},
- gopls = {},
+ -- gopls = {},
-- pyright = {},
-- rust_analyzer = {},
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
@@ -323,10 +354,8 @@ return {
-- 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 = {},
- -- for astro
-
+ -- But for many setups, the LSP (`ts_ls`) will work just fine
+ -- ts_ls = {},
--
lua_ls = {
@@ -358,7 +387,6 @@ return {
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
"stylua", -- Used to format Lua code
- "jsdoc",
})
require("mason-tool-installer").setup({ ensure_installed = ensure_installed })
@@ -368,7 +396,7 @@ return {
local server = servers[server_name] or {}
-- This handles overriding only values explicitly passed
-- by the server configuration above. Useful when disabling
- -- certain features of an LSP (for example, turning off formatting for tsserver)
+ -- certain features of an LSP (for example, turning off formatting for ts_ls)
server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {})
require("lspconfig")[server_name].setup(server)
end,
@@ -379,12 +407,13 @@ return {
{ -- Autoformat
"stevearc/conform.nvim",
- lazy = false,
+ event = { "BufWritePre" },
+ cmd = { "ConformInfo" },
keys = {
{
"<leader>f",
function()
- require("conform").format({ async = true, lsp_fallback = true })
+ require("conform").format({ async = true, lsp_format = "fallback" })
end,
mode = "",
desc = "[F]ormat buffer",
@@ -397,22 +426,24 @@ return {
-- have a well standardized coding style. You can add additional
-- languages here or re-enable it for the disabled ones.
local disable_filetypes = { c = true, cpp = true }
+ local lsp_format_opt
+ if disable_filetypes[vim.bo[bufnr].filetype] then
+ lsp_format_opt = "never"
+ else
+ lsp_format_opt = "fallback"
+ end
return {
timeout_ms = 500,
- lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
+ lsp_format = lsp_format_opt,
}
end,
formatters_by_ft = {
lua = { "stylua" },
- go = { "gofmt", "goimports" },
- css = { { "prettierd", "prettier" } },
- -- html = { { "prettierd", "prettier" } },
-- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" },
--
- -- You can use a sub-list to tell conform to run *until* a formatter
- -- is found.
- -- javascript = { { "prettierd", "prettier" } },
+ -- You can use 'stop_after_first' to run the first available formatter from the list
+ -- javascript = { "prettierd", "prettier", stop_after_first = true },
},
},
},
@@ -520,6 +551,11 @@ return {
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
}),
sources = {
+ {
+ name = "lazydev",
+ -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
+ group_index = 0,
+ },
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "path" },
@@ -561,7 +597,7 @@ return {
--
-- Examples:
-- - va) - [V]isually select [A]round [)]paren
- -- - yinq - [Y]ank [I]nside [N]ext [']quote
+ -- - yinq - [Y]ank [I]nside [N]ext [Q]uote
-- - ci' - [C]hange [I]nside [']quote
require("mini.ai").setup({ n_lines = 500 })
@@ -594,6 +630,8 @@ return {
{ -- Highlight, edit, and navigate code
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
+ main = "nvim-treesitter.configs", -- Sets main module to use for opts
+ -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
opts = {
ensure_installed = {
"bash",
@@ -603,14 +641,10 @@ return {
"lua",
"luadoc",
"markdown",
+ "markdown_inline",
+ "query",
"vim",
"vimdoc",
- "go",
- "json",
- "yaml",
- "toml",
- "gomod",
- "gosum",
},
-- Autoinstall languages that are not installed
auto_install = true,
@@ -621,60 +655,14 @@ return {
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
additional_vim_regex_highlighting = { "ruby" },
},
- indent = { enable = true, disable = { "ruby", "go" } },
- },
- config = function(_, opts)
- -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
-
- -- Prefer git instead of curl in order to improve connectivity in some environments
- require("nvim-treesitter.install").prefer_git = true
- ---@diagnostic disable-next-line: missing-fields
- require("nvim-treesitter.configs").setup(opts)
-
- -- There are additional nvim-treesitter modules that you can use to interact
- -- with nvim-treesitter. You should go explore a few and see what interests you:
- --
- -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
- -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
- -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
- end,
- },
- {
- "folke/trouble.nvim",
- opts = {}, -- for default options, refer to the configuration section for custom setup.
- cmd = "Trouble",
- keys = {
- {
- "<leader>xx",
- "<cmd>Trouble diagnostics toggle<cr>",
- desc = "Diagnostics (Trouble)",
- },
- {
- "<leader>xX",
- "<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
- desc = "Buffer Diagnostics (Trouble)",
- },
- {
- "<leader>cs",
- "<cmd>Trouble symbols toggle focus=false<cr>",
- desc = "Symbols (Trouble)",
- },
- {
- "<leader>cl",
- "<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
- desc = "LSP Definitions / references / ... (Trouble)",
- },
- {
- "<leader>xL",
- "<cmd>Trouble loclist toggle<cr>",
- desc = "Location List (Trouble)",
- },
- {
- "<leader>xQ",
- "<cmd>Trouble qflist toggle<cr>",
- desc = "Quickfix List (Trouble)",
- },
+ indent = { enable = true, disable = { "ruby" } },
},
+ -- There are additional nvim-treesitter modules that you can use to interact
+ -- with nvim-treesitter. You should go explore a few and see what interests you:
+ --
+ -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
+ -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
+ -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
},
}