Restructure and simply Neovim config a bit
This commit is contained in:
parent
359c4538c5
commit
9375e57331
12
nvim/lsp/lua_ls.lua
Normal file
12
nvim/lsp/lua_ls.lua
Normal file
@ -0,0 +1,12 @@
|
||||
return {
|
||||
settings = {
|
||||
Lua = {
|
||||
completion = {
|
||||
callSnippet = "Replace",
|
||||
},
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -1,11 +1,25 @@
|
||||
-- [[ Basic Keymaps ]]
|
||||
local keymap = vim.keymap.set
|
||||
|
||||
vim.keymap.set("n", "<Esc>", "<cmd>nohlsearch<CR>")
|
||||
vim.keymap.set("n", "<leader>f", vim.diagnostic.setloclist, { desc = "Open diagnostic quick[f]ix list" })
|
||||
vim.keymap.set("n", "<leader>q", "<cmd>q<CR>")
|
||||
vim.keymap.set("n", "<leader>Q", "<cmd>qa<CR>")
|
||||
vim.keymap.set("t", "<Esc><Esc>", "<C-\\><C-n>", { desc = "Exit terminal mode" })
|
||||
vim.keymap.set("n", "<C-h>", "<C-w><C-h>", { desc = "Move focus to the left window" })
|
||||
vim.keymap.set("n", "<C-l>", "<C-w><C-l>", { desc = "Move focus to the right window" })
|
||||
vim.keymap.set("n", "<C-j>", "<C-w><C-j>", { desc = "Move focus to the lower window" })
|
||||
vim.keymap.set("n", "<C-k>", "<C-w><C-k>", { desc = "Move focus to the upper window" })
|
||||
-- Normal mode
|
||||
keymap("n", "<Esc>", "<cmd>nohlsearch<CR>")
|
||||
keymap("n", "<leader>f", vim.diagnostic.setloclist, { desc = "Open diagnostic quick[f]ix list" })
|
||||
keymap("n", "<leader>w", "<cmd>w!<CR>", { desc = "[w]rite current file", silent = true })
|
||||
keymap("n", "<leader>q", "<cmd>q<CR>", { desc = "[q]uit current buffer", silent = true })
|
||||
keymap("n", "<leader>Q", "<cmd>qa<CR>", { desc = "[Q]uit completely", silent = true })
|
||||
keymap("n", "<Leader>fb", ":lua vim.lsp.buf.format()<CR>", { desc = "[f]ormat [b]uffer", silent = true })
|
||||
keymap("n", "<C-h>", "<C-w><C-h>", { desc = "Move focus to the left window" })
|
||||
keymap("n", "<C-l>", "<C-w><C-l>", { desc = "Move focus to the right window" })
|
||||
keymap("n", "<C-j>", "<C-w><C-j>", { desc = "Move focus to the lower window" })
|
||||
keymap("n", "<C-k>", "<C-w><C-k>", { desc = "Move focus to the upper window" })
|
||||
keymap(
|
||||
"n",
|
||||
"gd",
|
||||
"<cmd>lua vim.lsp.buf.definition()<CR>",
|
||||
{ desc = "[g]o to [d]efinition", noremap = true, silent = true }
|
||||
)
|
||||
|
||||
-- Visual mode
|
||||
keymap("v", "<Leader>p", '"_dP', { desc = "[p]aste without overwriting default register" })
|
||||
|
||||
-- Terminal mode
|
||||
keymap("t", "<Esc>", "<C-\\><C-n>", { desc = "Exit terminal mode" })
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
return {
|
||||
{
|
||||
"lewis6991/gitsigns.nvim",
|
||||
opts = {
|
||||
signs = {
|
||||
add = { text = "+" },
|
||||
change = { text = "~" },
|
||||
delete = { text = "_" },
|
||||
topdelete = { text = "‾" },
|
||||
changedelete = { text = "~" },
|
||||
},
|
||||
},
|
||||
},
|
||||
-- {
|
||||
-- "kdheepak/lazygit.nvim",
|
||||
-- lazy = false,
|
||||
-- cmd = {
|
||||
-- "LazyGit",
|
||||
-- "LazyGitConfig",
|
||||
-- "LazyGitCurrentFile",
|
||||
-- "LazyGitFilter",
|
||||
-- "LazyGitFilterCurrentFile",
|
||||
-- },
|
||||
-- keys = {
|
||||
-- { "<leader>gs", "<cmd>LazyGit<cr>", desc = "LazyGit" },
|
||||
-- },
|
||||
-- },
|
||||
}
|
||||
@ -1,47 +0,0 @@
|
||||
return {
|
||||
"folke/which-key.nvim",
|
||||
event = "VimEnter",
|
||||
opts = {
|
||||
delay = 0,
|
||||
icons = {
|
||||
mappings = vim.g.have_nerd_font,
|
||||
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
|
||||
spec = {
|
||||
{ "<leader>s", group = "[S]earch" },
|
||||
{ "<leader>e", group = "[E]xplorer/Tree" },
|
||||
{ "<leader>t", group = "[T]oggle" },
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -1,206 +0,0 @@
|
||||
return {
|
||||
{
|
||||
"folke/lazydev.nvim",
|
||||
ft = "lua",
|
||||
opts = {
|
||||
library = {
|
||||
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
{ "mason-org/mason.nvim", opts = {} },
|
||||
"mason-org/mason-lspconfig.nvim",
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
{ "j-hui/fidget.nvim", opts = {} },
|
||||
"saghen/blink.cmp",
|
||||
},
|
||||
config = function()
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }),
|
||||
callback = function(event)
|
||||
local map = function(keys, func, desc, mode)
|
||||
mode = mode or "n"
|
||||
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc })
|
||||
end
|
||||
vim.lsp.set_log_level("WARN")
|
||||
-- Rename the variable under your cursor.
|
||||
map("grn", vim.lsp.buf.rename, "[R]e[n]ame")
|
||||
-- Execute a code action, usually your cursor needs to be on top of an error
|
||||
map("gra", vim.lsp.buf.code_action, "[G]oto Code [A]ction", { "n", "x" })
|
||||
-- Find references for the word under your cursor.
|
||||
map("grr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
|
||||
-- Jump to the implementation of the word under your cursor.
|
||||
map("gri", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation")
|
||||
-- Jump to the definition of the word under your cursor.
|
||||
map("grd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition")
|
||||
-- WARN: This is not Goto Definition, this is Goto Declaration.
|
||||
map("grD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
|
||||
-- Fuzzy find all the symbols in your current document.
|
||||
map("gO", require("telescope.builtin").lsp_document_symbols, "Open Document Symbols")
|
||||
-- Fuzzy find all the symbols in your current workspace.
|
||||
map("gW", require("telescope.builtin").lsp_dynamic_workspace_symbols, "Open Workspace Symbols")
|
||||
-- Jump to the type of the word under your cursor.
|
||||
map("grt", require("telescope.builtin").lsp_type_definitions, "[G]oto [T]ype Definition")
|
||||
|
||||
-- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
|
||||
---@param client vim.lsp.Client
|
||||
---@param method vim.lsp.protocol.Method
|
||||
---@param bufnr? integer some lsp support methods only in specific files
|
||||
---@return boolean
|
||||
local function client_supports_method(client, method, bufnr)
|
||||
if vim.fn.has("nvim-0.11") == 1 then
|
||||
return client:supports_method(method, bufnr)
|
||||
else
|
||||
return client.supports_method(method, { bufnr = bufnr })
|
||||
end
|
||||
end
|
||||
|
||||
-- The following two autocommands are used to highlight references of the
|
||||
-- word under your cursor when your cursor rests there for a little while.
|
||||
-- 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_supports_method(
|
||||
client,
|
||||
vim.lsp.protocol.Methods.textDocument_documentHighlight,
|
||||
event.buf
|
||||
)
|
||||
then
|
||||
local highlight_augroup =
|
||||
vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false })
|
||||
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
||||
buffer = event.buf,
|
||||
group = highlight_augroup,
|
||||
callback = vim.lsp.buf.document_highlight,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
||||
buffer = event.buf,
|
||||
group = highlight_augroup,
|
||||
callback = vim.lsp.buf.clear_references,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("LspDetach", {
|
||||
group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }),
|
||||
callback = function(event2)
|
||||
vim.lsp.buf.clear_references()
|
||||
vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf })
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- 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_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf)
|
||||
then
|
||||
map("<leader>th", function()
|
||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf }))
|
||||
end, "[T]oggle Inlay [H]ints")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Diagnostic Config
|
||||
-- See :help vim.diagnostic.Opts
|
||||
vim.diagnostic.config({
|
||||
severity_sort = true,
|
||||
float = { border = "rounded", source = "if_many" },
|
||||
underline = { severity = vim.diagnostic.severity.ERROR },
|
||||
signs = vim.g.have_nerd_font and {
|
||||
text = {
|
||||
[vim.diagnostic.severity.ERROR] = " ",
|
||||
[vim.diagnostic.severity.WARN] = " ",
|
||||
[vim.diagnostic.severity.INFO] = " ",
|
||||
[vim.diagnostic.severity.HINT] = " ",
|
||||
},
|
||||
} or {},
|
||||
virtual_text = {
|
||||
source = "if_many",
|
||||
spacing = 2,
|
||||
format = function(diagnostic)
|
||||
local diagnostic_message = {
|
||||
[vim.diagnostic.severity.ERROR] = diagnostic.message,
|
||||
[vim.diagnostic.severity.WARN] = diagnostic.message,
|
||||
[vim.diagnostic.severity.INFO] = diagnostic.message,
|
||||
[vim.diagnostic.severity.HINT] = diagnostic.message,
|
||||
}
|
||||
return diagnostic_message[diagnostic.severity]
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
local capabilities = require("blink.cmp").get_lsp_capabilities()
|
||||
local servers = {
|
||||
terraformls = {
|
||||
filetypes = { "terraform", "terraform-vars", "hcl" },
|
||||
cmd = {
|
||||
"terraform-ls",
|
||||
"serve",
|
||||
"-log-file",
|
||||
vim.fs.dirname(require("vim.lsp.log").get_filename()) .. "/terraform-ls.log",
|
||||
},
|
||||
},
|
||||
lua_ls = {
|
||||
settings = {
|
||||
Lua = {
|
||||
completion = {
|
||||
callSnippet = "Replace",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- Ensure the servers and tools above are installed
|
||||
--
|
||||
-- To check the current status of installed tools and/or manually install
|
||||
-- other tools, you can run
|
||||
-- :Mason
|
||||
local ensure_installed = vim.tbl_keys(servers or {})
|
||||
vim.list_extend(ensure_installed, {
|
||||
-- LSPs
|
||||
"json-lsp",
|
||||
"lua_ls",
|
||||
"ruby_lsp",
|
||||
"rubocop",
|
||||
"rust_analyzer",
|
||||
"terraformls",
|
||||
-- Formatters
|
||||
"fixjson",
|
||||
"goimports",
|
||||
"hclfmt",
|
||||
"prettierd",
|
||||
"shellharden",
|
||||
"stylua",
|
||||
"yamlfix",
|
||||
--- Linters
|
||||
"swiftlint",
|
||||
})
|
||||
require("mason-tool-installer").setup({ ensure_installed = ensure_installed })
|
||||
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
|
||||
automatic_enable = true,
|
||||
automatic_installation = false,
|
||||
handlers = {
|
||||
function(server_name)
|
||||
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 ts_ls)
|
||||
server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {})
|
||||
require("lspconfig")[server_name].setup(server)
|
||||
end,
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
@ -1,14 +1,14 @@
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||
if vim.v.shell_error ~= 0 then
|
||||
error("Error cloning lazy.nvim:\n" .. out)
|
||||
end
|
||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||
if vim.v.shell_error ~= 0 then
|
||||
error("Error cloning lazy.nvim:\n" .. out)
|
||||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
require("lazy").setup({
|
||||
spec = "config.lazy",
|
||||
change_detection = { notify = false },
|
||||
spec = { import = "plugins" },
|
||||
change_detection = { notify = false },
|
||||
})
|
||||
|
||||
@ -1,37 +1,49 @@
|
||||
vim.g.have_nerd_font = true
|
||||
vim.o.guifont = "Inconsolata Patched G:h12"
|
||||
if vim.g.neovide then
|
||||
vim.opt.cmdheight = 0
|
||||
vim.o.linespace = 5
|
||||
vim.g.neovide_cursor_animation_length = 0
|
||||
vim.g.neovide_scroll_animation_length = 0
|
||||
end
|
||||
vim.opt.number = true
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.signcolumn = "yes"
|
||||
vim.opt.mouse = "a"
|
||||
-- Don't show the mode, since it's already in the status line
|
||||
vim.opt.showmode = false
|
||||
local opt = vim.opt
|
||||
|
||||
-- Columns and gutters
|
||||
opt.colorcolumn = "80" -- Highlight column 80
|
||||
opt.number = true -- Line numbers in the gutter
|
||||
opt.relativenumber = true -- Relative line numbers in the gutter
|
||||
opt.signcolumn = "yes:1" -- Sign column in the gutter always visible
|
||||
|
||||
-- Indentation
|
||||
opt.autoindent = true -- Enable auto-indentation
|
||||
opt.breakindent = true -- ?
|
||||
opt.expandtab = true -- Default to spaces instead of tabs
|
||||
opt.shiftround = true -- Round indent to multiple of shift-width
|
||||
opt.shiftwidth = 4 -- Number of spaces when auto-indenting
|
||||
opt.softtabstop = 4 -- Number of spaces for a tab when editing
|
||||
opt.tabstop = 4 -- Number of spaces for a tab
|
||||
|
||||
-- Display and adornments
|
||||
opt.cursorline = true -- Highlight current line
|
||||
opt.guifont = "Inconsolata Patched G:h12"
|
||||
opt.list = true -- Show whitespace characters
|
||||
opt.listchars = { tab = "» ", trail = "○", nbsp = "␣", lead = "•" }
|
||||
opt.scrolloff = 3 -- Show 3 lines above and below cursor
|
||||
opt.showmode = false -- Don't show the mode since it's in our statusline
|
||||
opt.termguicolors = true -- Use true terminal colors
|
||||
opt.virtualedit = "block"
|
||||
opt.winborder = "rounded" -- Rounded borders for windows
|
||||
|
||||
-- Behavior
|
||||
opt.confirm = true
|
||||
opt.ignorecase = true -- Ignore case in search and commands
|
||||
opt.inccommand = "split" -- Preview substitutions live
|
||||
opt.mouse = "a" -- Turn on mouse support
|
||||
opt.smartcase = true -- ?
|
||||
opt.splitbelow = true
|
||||
opt.splitright = true
|
||||
opt.timeoutlen = 1000 -- Command timeout length
|
||||
opt.undofile = true
|
||||
opt.updatetime = 250 -- ?
|
||||
|
||||
-- Clipboard
|
||||
-- Sync clipboard between OS and Neovim.
|
||||
vim.schedule(function()
|
||||
vim.opt.clipboard = "unnamedplus"
|
||||
vim.opt.clipboard = "unnamedplus"
|
||||
end)
|
||||
|
||||
vim.opt.timeoutlen = 1000
|
||||
vim.opt.breakindent = true
|
||||
vim.opt.undofile = true
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.smartcase = true
|
||||
vim.opt.updatetime = 250
|
||||
vim.opt.timeoutlen = 300
|
||||
vim.opt.splitright = true
|
||||
vim.opt.splitbelow = true
|
||||
vim.opt.list = true
|
||||
vim.opt.listchars = { tab = "» ", trail = "○", nbsp = "␣", lead = "•" }
|
||||
-- Preview substitutions live, as you type!
|
||||
vim.opt.inccommand = "split"
|
||||
vim.opt.cursorline = true
|
||||
vim.opt.scrolloff = 5
|
||||
vim.opt.confirm = true
|
||||
vim.opt.virtualedit = "block"
|
||||
-- Features
|
||||
vim.cmd.filetype("plugin indent on")
|
||||
vim.g.have_nerd_font = true
|
||||
|
||||
14
nvim/lua/plugins/10-git.lua
Normal file
14
nvim/lua/plugins/10-git.lua
Normal file
@ -0,0 +1,14 @@
|
||||
return {
|
||||
{
|
||||
"lewis6991/gitsigns.nvim",
|
||||
opts = {
|
||||
signs = {
|
||||
add = { text = "+" },
|
||||
change = { text = "~" },
|
||||
delete = { text = "_" },
|
||||
topdelete = { text = "‾" },
|
||||
changedelete = { text = "~" },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
19
nvim/lua/plugins/20-which-key.lua
Normal file
19
nvim/lua/plugins/20-which-key.lua
Normal file
@ -0,0 +1,19 @@
|
||||
return {
|
||||
"folke/which-key.nvim",
|
||||
event = "VimEnter",
|
||||
opts = {
|
||||
delay = 0,
|
||||
icons = {
|
||||
mappings = vim.g.have_nerd_font,
|
||||
keys = vim.g.have_nerd_font,
|
||||
},
|
||||
|
||||
-- Document existing key chains
|
||||
spec = {
|
||||
{ "<leader>s", group = "[S]earch" },
|
||||
{ "<leader>e", group = "[E]xplorer/Tree" },
|
||||
{ "<leader>t", group = "[T]oggle" },
|
||||
{ "<leader>g", group = "[G]oto/Actions" },
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -1,3 +1,5 @@
|
||||
local keymap = vim.keymap.set
|
||||
|
||||
return {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
event = "VimEnter",
|
||||
@ -32,32 +34,32 @@ return {
|
||||
|
||||
-- Define these keys here since they require access to runtime values
|
||||
local builtin = require("telescope.builtin")
|
||||
vim.keymap.set("n", "<leader>sh", builtin.help_tags, { desc = "[S]earch [H]elp" })
|
||||
vim.keymap.set("n", "<leader>sk", builtin.keymaps, { desc = "[S]earch [K]eymaps" })
|
||||
vim.keymap.set("n", "<leader>sf", builtin.find_files, { desc = "[S]earch [F]iles" })
|
||||
vim.keymap.set("n", "<leader>ss", builtin.builtin, { desc = "[S]earch [S]elect Telescope" })
|
||||
vim.keymap.set("n", "<leader>sw", builtin.grep_string, { desc = "[S]earch current [W]ord" })
|
||||
vim.keymap.set("n", "<leader>sg", builtin.live_grep, { desc = "[S]earch by [G]rep" })
|
||||
vim.keymap.set("n", "<leader>sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" })
|
||||
vim.keymap.set("n", "<leader>sr", builtin.resume, { desc = "[S]earch [R]esume" })
|
||||
vim.keymap.set("n", "<leader>s.", builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
||||
vim.keymap.set("n", "<leader><leader>", builtin.buffers, { desc = "[ ] Find existing buffers" })
|
||||
keymap("n", "<leader>sh", builtin.help_tags, { desc = "[S]earch [H]elp" })
|
||||
keymap("n", "<leader>sk", builtin.keymaps, { desc = "[S]earch [K]eymaps" })
|
||||
keymap("n", "<leader>sf", builtin.find_files, { desc = "[S]earch [F]iles" })
|
||||
keymap("n", "<leader>ss", builtin.builtin, { desc = "[S]earch [S]elect Telescope" })
|
||||
keymap("n", "<leader>sw", builtin.grep_string, { desc = "[S]earch current [W]ord" })
|
||||
keymap("n", "<leader>sg", builtin.live_grep, { desc = "[S]earch by [G]rep" })
|
||||
keymap("n", "<leader>sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" })
|
||||
keymap("n", "<leader>sr", builtin.resume, { desc = "[S]earch [R]esume" })
|
||||
keymap("n", "<leader>s.", builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
||||
keymap("n", "<leader><leader>", builtin.buffers, { desc = "[ ] Find existing buffers" })
|
||||
|
||||
vim.keymap.set("n", "<leader>/", function()
|
||||
keymap("n", "<leader>/", function()
|
||||
builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({
|
||||
winblend = 10,
|
||||
previewer = false,
|
||||
}))
|
||||
end, { desc = "[/] Fuzzily search in current buffer" })
|
||||
|
||||
vim.keymap.set("n", "<leader>s/", function()
|
||||
keymap("n", "<leader>s/", function()
|
||||
builtin.live_grep({
|
||||
grep_open_files = true,
|
||||
prompt_title = "Live Grep in Open Files",
|
||||
})
|
||||
end, { desc = "[S]earch [/] in Open Files" })
|
||||
|
||||
vim.keymap.set("n", "<leader>sn", function()
|
||||
keymap("n", "<leader>sn", function()
|
||||
builtin.find_files({ cwd = vim.fn.stdpath("config") })
|
||||
end, { desc = "[S]earch [N]eovim files" })
|
||||
end,
|
||||
147
nvim/lua/plugins/40-lsp.lua
Normal file
147
nvim/lua/plugins/40-lsp.lua
Normal file
@ -0,0 +1,147 @@
|
||||
local servers = {
|
||||
-- LSPs
|
||||
"json-lsp",
|
||||
"lua_ls",
|
||||
"ruby_lsp",
|
||||
"rubocop",
|
||||
"rust_analyzer",
|
||||
"terraformls",
|
||||
-- Formatters
|
||||
"fixjson",
|
||||
"goimports",
|
||||
"hclfmt",
|
||||
"prettierd",
|
||||
"shellharden",
|
||||
"stylua",
|
||||
"yamlfix",
|
||||
--- Linters
|
||||
"swiftlint",
|
||||
}
|
||||
|
||||
return {
|
||||
{
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
dependencies = {
|
||||
"mason-org/mason-lspconfig.nvim",
|
||||
},
|
||||
opts = {
|
||||
ensure_installed = servers,
|
||||
},
|
||||
},
|
||||
{
|
||||
"mason-org/mason-lspconfig.nvim",
|
||||
opts = {
|
||||
ensure_installed = {},
|
||||
automatic_enable = true,
|
||||
automatic_installation = false,
|
||||
},
|
||||
dependencies = {
|
||||
{ "mason-org/mason.nvim", opts = {} },
|
||||
"neovim/nvim-lspconfig",
|
||||
},
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
"mason-org/mason.nvim",
|
||||
"mason-org/mason-lspconfig.nvim",
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
{ "j-hui/fidget.nvim", opts = {} },
|
||||
"saghen/blink.cmp",
|
||||
},
|
||||
config = function()
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }),
|
||||
callback = function(event)
|
||||
local map = function(keys, func, desc, mode)
|
||||
vim.keymap.set(mode or "n", keys, func, { buffer = event.buf, desc = "LSP: " .. desc })
|
||||
end
|
||||
|
||||
map("grn", vim.lsp.buf.rename, "[R]e[n]ame")
|
||||
map("ga", vim.lsp.buf.code_action, "[g]oto [a]ction", { "n", "x" })
|
||||
map("gtr", require("telescope.builtin").lsp_references, "[g]o[t]o [r]eferences")
|
||||
map("gti", require("telescope.builtin").lsp_implementations, "[g]o[t]o [i]mplementation")
|
||||
map("gtd", require("telescope.builtin").lsp_definitions, "[g]o[t]o [d]efinition")
|
||||
map("gtD", vim.lsp.buf.declaration, "[g]o[t]o [D]eclaration")
|
||||
map("gtt", require("telescope.builtin").lsp_type_definitions, "[g]o[t]o [t]ype Definition")
|
||||
map("gsb", require("telescope.builtin").lsp_document_symbols, "[g]oto [s]ymbols in [b]uffer")
|
||||
map(
|
||||
"gsw",
|
||||
require("telescope.builtin").lsp_dynamic_workspace_symbols,
|
||||
"[g]oto [s]ymbols in [w]orkspace"
|
||||
)
|
||||
|
||||
local client = vim.lsp.get_client_by_id(event.data.client_id)
|
||||
local augroup = vim.api.nvim_create_augroup
|
||||
local autocmd = vim.api.nvim_create_autocmd
|
||||
if not client then
|
||||
return
|
||||
end
|
||||
|
||||
if client:supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) then
|
||||
local highlight_augroup = augroup("kickstart-lsp-highlight", { clear = false })
|
||||
autocmd({ "CursorHold", "CursorHoldI" }, {
|
||||
buffer = event.buf,
|
||||
group = highlight_augroup,
|
||||
callback = vim.lsp.buf.document_highlight,
|
||||
})
|
||||
autocmd({ "CursorMoved", "CursorMovedI" }, {
|
||||
buffer = event.buf,
|
||||
group = highlight_augroup,
|
||||
callback = vim.lsp.buf.clear_references,
|
||||
})
|
||||
autocmd("LspDetach", {
|
||||
group = augroup("kickstart-lsp-detach", { clear = true }),
|
||||
callback = function(event2)
|
||||
vim.lsp.buf.clear_references()
|
||||
vim.api.nvim_clear_autocmds({
|
||||
group = "kickstart-lsp-highlight",
|
||||
buffer = event2.buf,
|
||||
})
|
||||
end,
|
||||
})
|
||||
end
|
||||
if client:supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then
|
||||
map("<leader>th", function()
|
||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf }))
|
||||
end, "[T]oggle Inlay [H]ints")
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
-- {
|
||||
|
||||
-- config = function()
|
||||
|
||||
-- -- Diagnostic Config
|
||||
-- -- See :help vim.diagnostic.Opts
|
||||
-- vim.diagnostic.config({
|
||||
-- severity_sort = true,
|
||||
-- float = { border = "rounded", source = "if_many" },
|
||||
-- underline = { severity = vim.diagnostic.severity.ERROR },
|
||||
-- signs = vim.g.have_nerd_font and {
|
||||
-- text = {
|
||||
-- [vim.diagnostic.severity.ERROR] = " ",
|
||||
-- [vim.diagnostic.severity.WARN] = " ",
|
||||
-- [vim.diagnostic.severity.INFO] = " ",
|
||||
-- [vim.diagnostic.severity.HINT] = " ",
|
||||
-- },
|
||||
-- } or {},
|
||||
-- virtual_text = {
|
||||
-- source = "if_many",
|
||||
-- spacing = 2,
|
||||
-- format = function(diagnostic)
|
||||
-- local diagnostic_message = {
|
||||
-- [vim.diagnostic.severity.ERROR] = diagnostic.message,
|
||||
-- [vim.diagnostic.severity.WARN] = diagnostic.message,
|
||||
-- [vim.diagnostic.severity.INFO] = diagnostic.message,
|
||||
-- [vim.diagnostic.severity.HINT] = diagnostic.message,
|
||||
-- }
|
||||
-- return diagnostic_message[diagnostic.severity]
|
||||
-- end,
|
||||
-- },
|
||||
-- })
|
||||
-- end,
|
||||
-- },
|
||||
@ -2,13 +2,8 @@ return {
|
||||
"yetone/avante.nvim",
|
||||
event = "VeryLazy",
|
||||
version = false,
|
||||
|
||||
---@module 'avante'
|
||||
---@type avante.Config
|
||||
opts = {
|
||||
build = vim.fn.has("win32") ~= 0
|
||||
and "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false"
|
||||
or "make",
|
||||
build = "make",
|
||||
provider = "claude",
|
||||
},
|
||||
dependencies = {
|
||||
@ -37,6 +37,8 @@ alias av="ansible-vault"
|
||||
# tool aliases
|
||||
if [[ -x "$(command -v nvim)" ]]; then
|
||||
alias vim="nvim"
|
||||
alias v="nvim"
|
||||
alias vv="NVIM_APPNAME=nvim-new nvim"
|
||||
fi
|
||||
if [[ -x "$(command -v highlight)" ]]; then
|
||||
alias ccat='highlight -O ansi --force'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user