feat: cleanup ts lsp, dapui color handling
This commit is contained in:
parent
c721d67a75
commit
df3a2f6e18
118
init.lua
118
init.lua
|
|
@ -115,24 +115,6 @@ require('lazy').setup({
|
|||
-- Git related plugins
|
||||
'tpope/vim-fugitive',
|
||||
'tpope/vim-rhubarb',
|
||||
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
|
||||
'lewis6991/gitsigns.nvim',
|
||||
opts = {
|
||||
signs = {
|
||||
add = { text = '+' },
|
||||
change = { text = '~' },
|
||||
delete = { text = '_' },
|
||||
topdelete = { text = '‾' },
|
||||
changedelete = { text = '~' },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
-- Autocompletion
|
||||
'hrsh7th/nvim-cmp',
|
||||
dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' },
|
||||
},
|
||||
|
||||
-- Useful plugin to show you pending keybinds.
|
||||
{
|
||||
|
|
@ -276,6 +258,18 @@ require('lazy').setup({
|
|||
-- },
|
||||
-- },
|
||||
-- pickers = {}
|
||||
pickers = {
|
||||
live_grep = {
|
||||
file_ignore_patterns = { 'node_modules', '.git', '.venv' },
|
||||
additional_args = function(_)
|
||||
return { '--hidden' }
|
||||
end,
|
||||
},
|
||||
find_files = {
|
||||
file_ignore_patterns = { 'node_modules', '.git', '.venv' },
|
||||
hidden = true,
|
||||
},
|
||||
},
|
||||
extensions = {
|
||||
['ui-select'] = {
|
||||
require('telescope.themes').get_dropdown(),
|
||||
|
|
@ -539,6 +533,8 @@ require('lazy').setup({
|
|||
-- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
|
||||
-- - settings (table): Override the default settings passed when initializing the server.
|
||||
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
|
||||
local mason_packages = vim.fn.stdpath 'data' .. '/mason/packages'
|
||||
local volar_path = mason_packages .. '/vue-language-server/node_modules/@vue/language-server'
|
||||
local servers = {
|
||||
clangd = {
|
||||
cmd = {
|
||||
|
|
@ -562,7 +558,39 @@ require('lazy').setup({
|
|||
'--log=error',
|
||||
},
|
||||
},
|
||||
gopls = {},
|
||||
gopls = {
|
||||
settings = {
|
||||
gopls = {
|
||||
gofumpt = true, -- A stricter gofmt
|
||||
codelenses = {
|
||||
gc_details = false,
|
||||
generate = true,
|
||||
regenerate_cgo = true,
|
||||
run_govulncheck = true,
|
||||
test = true,
|
||||
tidy = true,
|
||||
upgrade_dependency = true,
|
||||
vendor = true,
|
||||
},
|
||||
hints = {
|
||||
assignVariableTypes = true,
|
||||
compositeLiteralFields = true,
|
||||
compositeLiteralTypes = true,
|
||||
constantValues = true,
|
||||
functionTypeParameters = true,
|
||||
parameterNames = true,
|
||||
rangeVariableTypes = true,
|
||||
},
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
shadow = true,
|
||||
},
|
||||
completeUnimported = true,
|
||||
staticcheck = true,
|
||||
usePlaceholders = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
dart = {
|
||||
force = true,
|
||||
},
|
||||
|
|
@ -575,13 +603,11 @@ require('lazy').setup({
|
|||
dockerls = {},
|
||||
-- gradle_ls = {},
|
||||
pyright = {},
|
||||
ts_ls = {},
|
||||
html = {},
|
||||
jsonls = {},
|
||||
-- jdtls = {},
|
||||
-- rust_analyzer = {},
|
||||
marksman = {},
|
||||
-- volar = {},
|
||||
yamlls = {},
|
||||
lua_ls = {
|
||||
settings = {
|
||||
|
|
@ -597,6 +623,30 @@ require('lazy').setup({
|
|||
tailwindcss = {},
|
||||
}
|
||||
|
||||
local vue_language_server_path = vim.fn.expand '$MASON/packages' .. '/vue-language-server' .. '/node_modules/@vue/language-server'
|
||||
local tsserver_filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }
|
||||
local vue_plugin = {
|
||||
name = '@vue/typescript-plugin',
|
||||
location = vue_language_server_path,
|
||||
languages = { 'vue' },
|
||||
configNamespace = 'typescript',
|
||||
}
|
||||
local vtsls_config = {
|
||||
settings = {
|
||||
vtsls = {
|
||||
tsserver = {
|
||||
globalPlugins = {
|
||||
vue_plugin,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
filetypes = tsserver_filetypes,
|
||||
}
|
||||
|
||||
vim.lsp.config('vtsls', vtsls_config)
|
||||
vim.lsp.enable { 'vtsls' }
|
||||
|
||||
-- Ensure the servers and tools above are installed
|
||||
--
|
||||
-- To check the current status of installed tools and/or manually install
|
||||
|
|
@ -907,7 +957,6 @@ require('lazy').setup({
|
|||
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
|
||||
-- These are some example plugins that I've included in the kickstart repository.
|
||||
-- Uncomment any of the lines below to enable them.
|
||||
require 'kickstart.plugins.autoformat',
|
||||
require 'kickstart.plugins.debug',
|
||||
|
||||
-- NOTE: The import below automatically adds your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
|
||||
|
|
@ -1006,3 +1055,28 @@ end, { desc = '[Q]uickfix [G]itdiff [V]iew (context-aware)' })
|
|||
|
||||
-- Quickfix with diagnostics
|
||||
vim.keymap.set('n', '<leader>qd', vim.diagnostic.setloclist, { desc = 'Open [Q]uickfix [D]iagnostic list' })
|
||||
|
||||
-- Create an autocommand to clear ANSI color codes from the DAP REPL
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'dap-repl',
|
||||
callback = function()
|
||||
-- Set an autocommand to clean the buffer whenever it's updated
|
||||
vim.api.nvim_create_autocmd('TextChanged', {
|
||||
buffer = vim.api.nvim_get_current_buf(),
|
||||
callback = function()
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false)
|
||||
local cleaned_lines = {}
|
||||
|
||||
for _, line in ipairs(lines) do
|
||||
-- Regex to find and remove ANSI escape sequences
|
||||
local cleaned = line:gsub('\27%[[0-9;]*m', '')
|
||||
table.insert(cleaned_lines, cleaned)
|
||||
end
|
||||
|
||||
-- Only update if changes were actually made to avoid infinite loops
|
||||
vim.api.nvim_buf_set_lines(buf, 0, -1, false, cleaned_lines)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,85 +0,0 @@
|
|||
return {
|
||||
}
|
||||
-- -- autoformat.lua
|
||||
-- --
|
||||
-- -- Use your language server to automatically format your code on save.
|
||||
-- -- Adds additional commands as well to manage the behavior
|
||||
--
|
||||
-- return {
|
||||
-- 'neovim/nvim-lspconfig',
|
||||
-- dependencies = {
|
||||
-- 'ray-x/go.nvim',
|
||||
-- 'ray-x/guihua.lua',
|
||||
-- },
|
||||
-- config = function()
|
||||
-- require("go").setup()
|
||||
-- -- Switch for controlling whether you want autoformatting.
|
||||
-- -- Use :KickstartFormatToggle to toggle autoformatting on or off
|
||||
-- local format_is_enabled = true
|
||||
-- vim.api.nvim_create_user_command('KickstartFormatToggle', function()
|
||||
-- format_is_enabled = not format_is_enabled
|
||||
-- print('Setting autoformatting to: ' .. tostring(format_is_enabled))
|
||||
-- end, {})
|
||||
--
|
||||
-- -- Create an augroup that is used for managing our formatting autocmds.
|
||||
-- -- We need one augroup per client to make sure that multiple clients
|
||||
-- -- can attach to the same buffer without interfering with each other.
|
||||
-- local _augroups = {}
|
||||
-- local get_augroup = function(client)
|
||||
-- if not _augroups[client.id] then
|
||||
-- local group_name = 'kickstart-lsp-format-' .. client.name
|
||||
-- local id = vim.api.nvim_create_augroup(group_name, { clear = true })
|
||||
-- _augroups[client.id] = id
|
||||
-- end
|
||||
--
|
||||
-- return _augroups[client.id]
|
||||
-- end
|
||||
--
|
||||
-- -- Whenever an LSP attaches to a buffer, we will run this function.
|
||||
-- --
|
||||
-- -- See `:help LspAttach` for more information about this autocmd event.
|
||||
-- vim.api.nvim_create_autocmd('LspAttach', {
|
||||
-- group = vim.api.nvim_create_augroup('kickstart-lsp-attach-format', { clear = true }),
|
||||
-- -- This is where we attach the autoformatting for reasonable clients
|
||||
-- callback = function(args)
|
||||
-- local client_id = args.data.client_id
|
||||
-- local client = vim.lsp.get_client_by_id(client_id)
|
||||
-- local bufnr = args.buf
|
||||
--
|
||||
-- -- Only attach to clients that support document formatting
|
||||
-- if not client.server_capabilities.documentFormattingProvider then
|
||||
-- return
|
||||
-- end
|
||||
--
|
||||
-- -- Tsserver usually works poorly. Sorry you work with bad languages
|
||||
-- -- You can remove this line if you know what you're doing :)
|
||||
-- if client.name == 'tsserver' then
|
||||
-- return
|
||||
-- end
|
||||
--
|
||||
-- -- Create an autocmd that will run *before* we save the buffer.
|
||||
-- -- Run the formatting command for the LSP that has just attached.
|
||||
-- vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
-- group = get_augroup(client),
|
||||
-- buffer = bufnr,
|
||||
-- callback = function()
|
||||
-- if not format_is_enabled then
|
||||
-- return
|
||||
-- end
|
||||
--
|
||||
-- if vim.bo.filetype == 'go' then
|
||||
-- require('go.format').goimport()
|
||||
-- else
|
||||
-- vim.lsp.buf.format {
|
||||
-- async = false,
|
||||
-- filter = function(c)
|
||||
-- return c.id == client.id
|
||||
-- end,
|
||||
-- }
|
||||
-- end
|
||||
-- end,
|
||||
-- })
|
||||
-- end,
|
||||
-- })
|
||||
-- end,
|
||||
-- }
|
||||
|
|
@ -135,6 +135,28 @@ return {
|
|||
-- Dap UI setup
|
||||
-- For more information, see |:help nvim-dap-ui|
|
||||
dapui.setup {
|
||||
layouts = {
|
||||
{
|
||||
-- The Sidebar (Left)
|
||||
elements = {
|
||||
{ id = 'scopes', size = 0.25 },
|
||||
{ id = 'breakpoints', size = 0.25 },
|
||||
{ id = 'stacks', size = 0.25 },
|
||||
{ id = 'watches', size = 0.25 },
|
||||
},
|
||||
position = 'left',
|
||||
size = 40,
|
||||
},
|
||||
{
|
||||
-- The Bottom Tray
|
||||
-- REMOVED "console" from here
|
||||
elements = {
|
||||
{ id = 'repl', size = 1.0 },
|
||||
},
|
||||
position = 'bottom',
|
||||
size = 10,
|
||||
},
|
||||
},
|
||||
-- Set icons to characters that are more likely to work in every terminal.
|
||||
-- Feel free to remove or use ones that you like more! :)
|
||||
-- Don't feel like these are good choices.
|
||||
|
|
@ -161,7 +183,7 @@ return {
|
|||
dap.defaults.fallback.exception_breakpoints = { 'Notice', 'Warning', 'Error', 'Exception' }
|
||||
|
||||
-- Install golang specific config
|
||||
require('dap-go').setup{
|
||||
require('dap-go').setup {
|
||||
delve = {
|
||||
detached = vim.fn.has 'win32' == 0,
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue