kickstart.nvim/after/plugin/defaults.lua

103 lines
3.7 KiB
Lua

local set = vim.opt
set.colorcolumn = "80,120"
set.cursorline = true
set.expandtab = true
set.list = true
set.shiftwidth = 2
set.splitbelow = true
set.splitright = true
set.swapfile = false
set.tabstop = 2
set.textwidth = 80
set.wrap = false
set.writebackup = false
vim.o.inccommand = "nosplit"
-- prev/next tab
vim.keymap.set('n', 'H', 'gT', { desc = 'Tab Left' })
vim.keymap.set('n', 'L', 'gt', { desc = 'Tab Right' })
-- line bubbling
vim.keymap.set('n', '<C-j>', ':m .+1<CR>==', { noremap = true, desc = 'Bubble Down' })
vim.keymap.set('n', '<C-k>', ':m .-2<CR>==', { noremap = true, desc = 'Bubble Up' }) -- conflicts with "signature help" from LSP
-- vim.keymap.set('i', '<C-j>', '<ESC>:m .+1<CR>==gi', { noremap = true, desc = 'Bubble Down' })
-- vim.keymap.set('i', '<C-k>', '<ESC>:m .-2<CR>==gi', { noremap = true, desc = 'Bubble Up' })
vim.keymap.set('v', '<C-k>', ":m '<-2<CR>gv=gv", { noremap = true, desc = 'Bubble Down' })
vim.keymap.set('v', '<C-j>', ":m '>+1<CR>gv=gv", { noremap = true, desc = 'Bubble Up' })
-- additional telescope triggers
vim.keymap.set('n', '<C-t>', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<C-g>', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sj', require('telescope.builtin').jumplist, { desc = '[S]earch [J]umplist' })
vim.keymap.set('n', '<leader>sj', require('telescope.builtin').jumplist, { desc = '[S]earch [J]umplist' })
vim.keymap.set('n', '<leader>ss', require('telescope.builtin').git_status, { desc = '[S]earch [S]tatus' })
vim.keymap.set('n', '<leader>sm', require('telescope.builtin').marks, { desc = '[S]earch [M]arks' })
-- Open file in vscode, for WCA and GPT stuff
vim.api.nvim_create_user_command(
'OpenInVSCode',
function(opts)
-- Using vim.fn.expand('%') to get the current file path
local filepath = vim.fn.expand('%:p') -- ':p' expands to full path
-- The command to open VS Code with the current file
os.execute('code ' .. filepath)
end,
{ desc = 'Open the current file in Visual Studio Code' }
)
-- local original_handler = vim.lsp.handlers["textDocument/definition"]
-- vim.lsp.handlers["textDocument/definition"] = function(err, result, ctx, config)
-- if result and vim.tbl_islist(result) and #result > 1 then
-- -- This handles multiple definitions. For example, jump to the first definition:
-- original_handler(err, {result[1]}, ctx, config)
-- else
-- -- Call the original handler otherwise
-- original_handler(err, result, ctx, config)
-- end
-- end
-- vim.keymap.set('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
-- copilot
-- vim.g.copilot_no_tab_map = "v:true"
-- vim.keymap.set('i', '<C-j>', '<silent><script><expr> <C-J> copilot#Accept("<CR>")',
-- { noremap = true, desc = 'Accept Copilot Suggestion' })
-- autoformatting
vim.keymap.set('n', '<leader>ft', ':KickstartFormatToggle<CR>', { desc = '[F]ormat [T]oggle' })
vim.diagnostic.config({
severity_sort = true,
virtual_text = {
source = false,
prefix = '',
format = function()
return ""
end,
},
float = {
source = "always",
format = function(diagnostic)
if diagnostic.source == 'eslint' then
return string.format(
'%s [%s]',
diagnostic.message,
diagnostic.user_data.lsp.code
)
end
return string.format('%s [%s]', diagnostic.message, diagnostic.source)
end,
},
})
local signs = { Error = "", Warn = "", Hint = "", Info = "i" }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end
-- vim: ts=2 sts=2 sw=2 et