config updates

# Conflicts:
#	init.lua
This commit is contained in:
smoon 2024-06-18 11:47:43 -07:00
parent ac78e7d9e7
commit 7336c66f16
1 changed files with 78 additions and 1 deletions

View File

@ -102,7 +102,7 @@ vim.g.have_nerd_font = false
vim.opt.number = true vim.opt.number = true
-- You can also add relative line numbers, to help with jumping. -- You can also add relative line numbers, to help with jumping.
-- Experiment for yourself to see if you like it! -- Experiment for yourself to see if you like it!
-- vim.opt.relativenumber = true vim.opt.relativenumber = true
-- Enable mouse mode, can be useful for resizing splits for example! -- Enable mouse mode, can be useful for resizing splits for example!
vim.opt.mouse = 'a' vim.opt.mouse = 'a'
@ -164,7 +164,13 @@ vim.opt.scrolloff = 10
-- See `:help hlsearch` -- See `:help hlsearch`
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>') vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
-- Diagnostic keymaps -- 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', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
@ -230,6 +236,7 @@ vim.opt.rtp:prepend(lazypath)
require('lazy').setup({ require('lazy').setup({
-- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
'tpope/vim-fugitive', -- Git commands in nvim
-- NOTE: Plugins can also be added by using a table, -- NOTE: Plugins can also be added by using a table,
-- with the first argument being the link and the following -- with the first argument being the link and the following
@ -333,6 +340,9 @@ require('lazy').setup({
-- you do for a plugin at the top level, you can do for a dependency. -- you do for a plugin at the top level, you can do for a dependency.
-- --
-- Use the `dependencies` key to specify the dependencies of a particular plugin -- Use the `dependencies` key to specify the dependencies of a particular plugin
{
'github/copilot.vim',
},
{ -- Fuzzy Finder (files, lsp, etc) { -- Fuzzy Finder (files, lsp, etc)
'nvim-telescope/telescope.nvim', 'nvim-telescope/telescope.nvim',
@ -618,6 +628,24 @@ require('lazy').setup({
-- But for many setups, the LSP (`tsserver`) will work just fine -- But for many setups, the LSP (`tsserver`) will work just fine
-- tsserver = {}, -- tsserver = {},
-- --
intelephense = {},
terraformls = {},
templ = {
filetypes = { 'templ' },
},
tsserver = {},
gopls = {
settings = {
gopls = {
analyses = {
unusedparams = true,
},
staticcheck = true,
gofumpt = true,
},
},
},
-- phan = {},
lua_ls = { lua_ls = {
-- cmd = {...}, -- cmd = {...},
@ -949,3 +977,52 @@ require('lazy').setup({
-- The line beneath this is called `modeline`. See `:help modeline` -- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et -- vim: ts=2 sts=2 sw=2 et
vim.filetype.add {
extension = {
templ = 'templ',
},
}
-- Toggle Auto formatting
vim.api.nvim_create_user_command('FormatDisable', function(args)
if args.bang then
-- FormatDisable! will disable formatting just for this buffer
vim.b.disable_autoformat = true
else
vim.g.disable_autoformat = true
end
end, {
desc = 'Disable autoformat-on-save',
bang = true,
})
vim.api.nvim_create_user_command('FormatEnable', function()
vim.b.disable_autoformat = false
vim.g.disable_autoformat = false
end, {
desc = 'Re-enable autoformat-on-save',
})
-- Automatically organize imports and format Go code on save
vim.api.nvim_create_autocmd('BufWritePre', {
pattern = '*.go',
callback = function()
local params = vim.lsp.util.make_range_params()
params.context = { only = { 'source.organizeImports' } }
-- buf_request_sync defaults to a 1000ms timeout. Depending on your
-- machine and codebase, you may want longer. Add an additional
-- argument after params if you find that you have to write the file
-- twice for changes to be saved.
-- E.g., vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 3000)
local result = vim.lsp.buf_request_sync(0, 'textDocument/codeAction', params)
for cid, res in pairs(result or {}) do
for _, r in pairs(res.result or {}) do
if r.edit then
local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or 'utf-16'
vim.lsp.util.apply_workspace_edit(r.edit, enc)
end
end
end
vim.lsp.buf.format { async = false }
end,
})