This commit is contained in:
TJ DeVries 2024-02-22 14:16:49 -05:00
parent f1d3a3c32f
commit 2022a26e28

106
init.lua
View File

@ -85,11 +85,11 @@ vim.g.maplocalleader = ' '
-- NOTE: You can change these options as you wish! -- NOTE: You can change these options as you wish!
-- For more options, you can see `:help option-list` -- For more options, you can see `:help option-list`
-- Set highlight on search
vim.opt.hlsearch = false
-- Make line numbers default -- Make line numbers default
vim.opt.number = true vim.opt.number = true
-- You can also add relative line numbers, for help with jumping.
-- Experiment for yourself to see if you like it!
-- vim.opt.relativenumber = true
-- Enable mouse mode -- Enable mouse mode
vim.opt.mouse = 'a' vim.opt.mouse = 'a'
@ -126,8 +126,17 @@ vim.opt.splitbelow = true
vim.opt.list = true vim.opt.list = true
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '' } vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '' }
-- Preview substitutions live
vim.opt.inccommand = 'split'
-- [[ Basic Keymaps ]] -- [[ Basic Keymaps ]]
-- Set highlight on search
vim.opt.hlsearch = true
-- Clear highlighting on pressing Escape
vim.keymap.set('n', '<Esc>', '<esc>:nohlsearch<CR>', { silent = true })
-- Keymaps for better default experience -- Keymaps for better default experience
-- See `:help vim.keymap.set()` -- See `:help vim.keymap.set()`
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
@ -301,7 +310,11 @@ require('lazy').setup({
-- You can put your default mappings / updates / etc. in here -- You can put your default mappings / updates / etc. in here
-- All the info you're looking for is in `:help telescope.setup()` -- All the info you're looking for is in `:help telescope.setup()`
-- --
-- defaults = {}, -- defaults = {
-- mappings = {
-- i = { ['<c-enter>'] = 'to_fuzzy_refine' },
-- },
-- },
-- pickers = {} -- pickers = {}
extensions = { extensions = {
['ui-select'] = { ['ui-select'] = {
@ -400,47 +413,53 @@ require('lazy').setup({
require('neodev').setup() require('neodev').setup()
-- This function gets run when an LSP connects to a particular buffer. -- This function gets run when an LSP connects to a particular buffer.
local on_attach = function(_, bufnr) -- That is to say, every time a new file is opened that is associated with
-- NOTE: Remember that lua is a real programming language, and as such it is possible -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this
-- to define small helper and utility functions so you don't have to repeat yourself -- function will be executed to configure the current buffer
-- many times. vim.api.nvim_create_autocmd('LspAttach', {
-- group = vim.api.nvim_create_augroup('custom-lsp-attach', { clear = true }),
-- In this case, we create a function that lets us more easily define mappings specific callback = function(event)
-- for LSP related items. It sets the mode, buffer and description for us each time. -- NOTE: Remember that lua is a real programming language, and as such it is possible
local nmap = function(keys, func, desc) -- to define small helper and utility functions so you don't have to repeat yourself
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = 'LSP: ' .. desc }) -- many times.
end --
-- 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 nmap = function(keys, func, desc)
vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
end
-- Important LSP Navigation keybinds -- Important LSP Navigation keybinds
-- --
-- Jump to the definition of the word under your cursor. -- Jump to the definition of the word under your cursor.
-- To jump back, press <C-T>. -- To jump back, press <C-T>.
nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
nmap('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') nmap('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
-- NOTE: This is not Goto Definition, this is Goto Declaration. -- WARN: This is not Goto Definition, this is Goto Declaration.
-- For example, in C this would take you to the header -- For example, in C this would take you to the header
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
-- Rename the variable under your cursor -- Rename the variable under your cursor
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame') nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
-- Execute a code action, usually your cursor needs to be on top of an error -- 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. -- or a suggestion from your LSP for this to activate.
nmap('<leader>ca', function() nmap('<leader>ca', function()
vim.lsp.buf.code_action { context = { only = { 'quickfix', 'refactor', 'source' } } } vim.lsp.buf.code_action { context = { only = { 'quickfix', 'refactor', 'source' } } }
end, '[C]ode [A]ction') end, '[C]ode [A]ction')
-- See `:help K` for why this keymap -- See `:help K` for why this keymap
nmap('K', vim.lsp.buf.hover, 'Hover Documentation') nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
-- Show the signature of the function you're currently completing. -- Show the signature of the function you're currently completing.
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation') nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
end end,
})
-- LSP servers and clients are able to communicate to each other what features they support. -- 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. -- By default, Neovim doesn't support everything that is in the LSP Specification.
@ -462,8 +481,14 @@ require('lazy').setup({
-- gopls = {}, -- gopls = {},
-- pyright = {}, -- pyright = {},
-- rust_analyzer = {}, -- rust_analyzer = {},
-- tsserver = {},
-- html = { filetypes = { 'html', 'twig', 'hbs'} }, -- html = { filetypes = { 'html', 'twig', 'hbs'} },
--
-- If you use something like typescript, where the tooling is as bad as the language,
-- then you might need to install and configure something like this:
-- https://github.com/pmizio/typescript-tools.nvim
--
-- If you only have simple needs for typescript, then you can probably just use tsserver
-- tsserver = {},
lua_ls = { lua_ls = {
-- cmd = {...}, -- cmd = {...},
@ -495,7 +520,6 @@ require('lazy').setup({
cmd = server.cmd, cmd = server.cmd,
settings = server.settings, settings = server.settings,
filetypes = server.filetypes, filetypes = server.filetypes,
on_attach = on_attach,
-- TODO: Think about what we wanna do here. -- TODO: Think about what we wanna do here.
-- capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities), -- capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities),
capabilities = server.capabilities or capabilities, capabilities = server.capabilities or capabilities,