Skip to content

Commit 7336c66

Browse files
committed
config updates
# Conflicts: # init.lua
1 parent ac78e7d commit 7336c66

File tree

1 file changed

+78
-1
lines changed

1 file changed

+78
-1
lines changed

init.lua

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ vim.g.have_nerd_font = false
102102
vim.opt.number = true
103103
-- You can also add relative line numbers, to help with jumping.
104104
-- Experiment for yourself to see if you like it!
105-
-- vim.opt.relativenumber = true
105+
vim.opt.relativenumber = true
106106

107107
-- Enable mouse mode, can be useful for resizing splits for example!
108108
vim.opt.mouse = 'a'
@@ -164,7 +164,13 @@ vim.opt.scrolloff = 10
164164
-- See `:help hlsearch`
165165
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
166166

167+
vim.opt.tabstop = 4
168+
vim.opt.shiftwidth = 4
169+
167170
-- Diagnostic keymaps
171+
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
172+
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
173+
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
168174
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
169175

170176
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
@@ -230,6 +236,7 @@ vim.opt.rtp:prepend(lazypath)
230236
require('lazy').setup({
231237
-- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
232238
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
239+
'tpope/vim-fugitive', -- Git commands in nvim
233240

234241
-- NOTE: Plugins can also be added by using a table,
235242
-- with the first argument being the link and the following
@@ -333,6 +340,9 @@ require('lazy').setup({
333340
-- you do for a plugin at the top level, you can do for a dependency.
334341
--
335342
-- Use the `dependencies` key to specify the dependencies of a particular plugin
343+
{
344+
'github/copilot.vim',
345+
},
336346

337347
{ -- Fuzzy Finder (files, lsp, etc)
338348
'nvim-telescope/telescope.nvim',
@@ -618,6 +628,24 @@ require('lazy').setup({
618628
-- But for many setups, the LSP (`tsserver`) will work just fine
619629
-- tsserver = {},
620630
--
631+
intelephense = {},
632+
terraformls = {},
633+
templ = {
634+
filetypes = { 'templ' },
635+
},
636+
tsserver = {},
637+
gopls = {
638+
settings = {
639+
gopls = {
640+
analyses = {
641+
unusedparams = true,
642+
},
643+
staticcheck = true,
644+
gofumpt = true,
645+
},
646+
},
647+
},
648+
-- phan = {},
621649

622650
lua_ls = {
623651
-- cmd = {...},
@@ -949,3 +977,52 @@ require('lazy').setup({
949977

950978
-- The line beneath this is called `modeline`. See `:help modeline`
951979
-- vim: ts=2 sts=2 sw=2 et
980+
981+
vim.filetype.add {
982+
extension = {
983+
templ = 'templ',
984+
},
985+
}
986+
987+
-- Toggle Auto formatting
988+
vim.api.nvim_create_user_command('FormatDisable', function(args)
989+
if args.bang then
990+
-- FormatDisable! will disable formatting just for this buffer
991+
vim.b.disable_autoformat = true
992+
else
993+
vim.g.disable_autoformat = true
994+
end
995+
end, {
996+
desc = 'Disable autoformat-on-save',
997+
bang = true,
998+
})
999+
vim.api.nvim_create_user_command('FormatEnable', function()
1000+
vim.b.disable_autoformat = false
1001+
vim.g.disable_autoformat = false
1002+
end, {
1003+
desc = 'Re-enable autoformat-on-save',
1004+
})
1005+
1006+
-- Automatically organize imports and format Go code on save
1007+
vim.api.nvim_create_autocmd('BufWritePre', {
1008+
pattern = '*.go',
1009+
callback = function()
1010+
local params = vim.lsp.util.make_range_params()
1011+
params.context = { only = { 'source.organizeImports' } }
1012+
-- buf_request_sync defaults to a 1000ms timeout. Depending on your
1013+
-- machine and codebase, you may want longer. Add an additional
1014+
-- argument after params if you find that you have to write the file
1015+
-- twice for changes to be saved.
1016+
-- E.g., vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 3000)
1017+
local result = vim.lsp.buf_request_sync(0, 'textDocument/codeAction', params)
1018+
for cid, res in pairs(result or {}) do
1019+
for _, r in pairs(res.result or {}) do
1020+
if r.edit then
1021+
local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or 'utf-16'
1022+
vim.lsp.util.apply_workspace_edit(r.edit, enc)
1023+
end
1024+
end
1025+
end
1026+
vim.lsp.buf.format { async = false }
1027+
end,
1028+
})

0 commit comments

Comments
 (0)