Skip to content

Commit df3a2f6

Browse files
author
Wil Simpson
committed
feat: cleanup ts lsp, dapui color handling
1 parent c721d67 commit df3a2f6

File tree

3 files changed

+119
-108
lines changed

3 files changed

+119
-108
lines changed

init.lua

Lines changed: 96 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -115,24 +115,6 @@ require('lazy').setup({
115115
-- Git related plugins
116116
'tpope/vim-fugitive',
117117
'tpope/vim-rhubarb',
118-
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
119-
'lewis6991/gitsigns.nvim',
120-
opts = {
121-
signs = {
122-
add = { text = '+' },
123-
change = { text = '~' },
124-
delete = { text = '_' },
125-
topdelete = { text = '' },
126-
changedelete = { text = '~' },
127-
},
128-
},
129-
},
130-
131-
{
132-
-- Autocompletion
133-
'hrsh7th/nvim-cmp',
134-
dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' },
135-
},
136118

137119
-- Useful plugin to show you pending keybinds.
138120
{
@@ -276,6 +258,18 @@ require('lazy').setup({
276258
-- },
277259
-- },
278260
-- pickers = {}
261+
pickers = {
262+
live_grep = {
263+
file_ignore_patterns = { 'node_modules', '.git', '.venv' },
264+
additional_args = function(_)
265+
return { '--hidden' }
266+
end,
267+
},
268+
find_files = {
269+
file_ignore_patterns = { 'node_modules', '.git', '.venv' },
270+
hidden = true,
271+
},
272+
},
279273
extensions = {
280274
['ui-select'] = {
281275
require('telescope.themes').get_dropdown(),
@@ -539,6 +533,8 @@ require('lazy').setup({
539533
-- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
540534
-- - settings (table): Override the default settings passed when initializing the server.
541535
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
536+
local mason_packages = vim.fn.stdpath 'data' .. '/mason/packages'
537+
local volar_path = mason_packages .. '/vue-language-server/node_modules/@vue/language-server'
542538
local servers = {
543539
clangd = {
544540
cmd = {
@@ -562,7 +558,39 @@ require('lazy').setup({
562558
'--log=error',
563559
},
564560
},
565-
gopls = {},
561+
gopls = {
562+
settings = {
563+
gopls = {
564+
gofumpt = true, -- A stricter gofmt
565+
codelenses = {
566+
gc_details = false,
567+
generate = true,
568+
regenerate_cgo = true,
569+
run_govulncheck = true,
570+
test = true,
571+
tidy = true,
572+
upgrade_dependency = true,
573+
vendor = true,
574+
},
575+
hints = {
576+
assignVariableTypes = true,
577+
compositeLiteralFields = true,
578+
compositeLiteralTypes = true,
579+
constantValues = true,
580+
functionTypeParameters = true,
581+
parameterNames = true,
582+
rangeVariableTypes = true,
583+
},
584+
analyses = {
585+
unusedparams = true,
586+
shadow = true,
587+
},
588+
completeUnimported = true,
589+
staticcheck = true,
590+
usePlaceholders = true,
591+
},
592+
},
593+
},
566594
dart = {
567595
force = true,
568596
},
@@ -575,13 +603,11 @@ require('lazy').setup({
575603
dockerls = {},
576604
-- gradle_ls = {},
577605
pyright = {},
578-
ts_ls = {},
579606
html = {},
580607
jsonls = {},
581608
-- jdtls = {},
582609
-- rust_analyzer = {},
583610
marksman = {},
584-
-- volar = {},
585611
yamlls = {},
586612
lua_ls = {
587613
settings = {
@@ -597,6 +623,30 @@ require('lazy').setup({
597623
tailwindcss = {},
598624
}
599625

626+
local vue_language_server_path = vim.fn.expand '$MASON/packages' .. '/vue-language-server' .. '/node_modules/@vue/language-server'
627+
local tsserver_filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }
628+
local vue_plugin = {
629+
name = '@vue/typescript-plugin',
630+
location = vue_language_server_path,
631+
languages = { 'vue' },
632+
configNamespace = 'typescript',
633+
}
634+
local vtsls_config = {
635+
settings = {
636+
vtsls = {
637+
tsserver = {
638+
globalPlugins = {
639+
vue_plugin,
640+
},
641+
},
642+
},
643+
},
644+
filetypes = tsserver_filetypes,
645+
}
646+
647+
vim.lsp.config('vtsls', vtsls_config)
648+
vim.lsp.enable { 'vtsls' }
649+
600650
-- Ensure the servers and tools above are installed
601651
--
602652
-- To check the current status of installed tools and/or manually install
@@ -907,7 +957,6 @@ require('lazy').setup({
907957
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
908958
-- These are some example plugins that I've included in the kickstart repository.
909959
-- Uncomment any of the lines below to enable them.
910-
require 'kickstart.plugins.autoformat',
911960
require 'kickstart.plugins.debug',
912961

913962
-- 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)' })
10061055

10071056
-- Quickfix with diagnostics
10081057
vim.keymap.set('n', '<leader>qd', vim.diagnostic.setloclist, { desc = 'Open [Q]uickfix [D]iagnostic list' })
1058+
1059+
-- Create an autocommand to clear ANSI color codes from the DAP REPL
1060+
vim.api.nvim_create_autocmd('FileType', {
1061+
pattern = 'dap-repl',
1062+
callback = function()
1063+
-- Set an autocommand to clean the buffer whenever it's updated
1064+
vim.api.nvim_create_autocmd('TextChanged', {
1065+
buffer = vim.api.nvim_get_current_buf(),
1066+
callback = function()
1067+
local buf = vim.api.nvim_get_current_buf()
1068+
local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false)
1069+
local cleaned_lines = {}
1070+
1071+
for _, line in ipairs(lines) do
1072+
-- Regex to find and remove ANSI escape sequences
1073+
local cleaned = line:gsub('\27%[[0-9;]*m', '')
1074+
table.insert(cleaned_lines, cleaned)
1075+
end
1076+
1077+
-- Only update if changes were actually made to avoid infinite loops
1078+
vim.api.nvim_buf_set_lines(buf, 0, -1, false, cleaned_lines)
1079+
end,
1080+
})
1081+
end,
1082+
})

lua/kickstart/plugins/autoformat.lua

Lines changed: 0 additions & 85 deletions
This file was deleted.

lua/kickstart/plugins/debug.lua

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,28 @@ return {
135135
-- Dap UI setup
136136
-- For more information, see |:help nvim-dap-ui|
137137
dapui.setup {
138+
layouts = {
139+
{
140+
-- The Sidebar (Left)
141+
elements = {
142+
{ id = 'scopes', size = 0.25 },
143+
{ id = 'breakpoints', size = 0.25 },
144+
{ id = 'stacks', size = 0.25 },
145+
{ id = 'watches', size = 0.25 },
146+
},
147+
position = 'left',
148+
size = 40,
149+
},
150+
{
151+
-- The Bottom Tray
152+
-- REMOVED "console" from here
153+
elements = {
154+
{ id = 'repl', size = 1.0 },
155+
},
156+
position = 'bottom',
157+
size = 10,
158+
},
159+
},
138160
-- Set icons to characters that are more likely to work in every terminal.
139161
-- Feel free to remove or use ones that you like more! :)
140162
-- Don't feel like these are good choices.
@@ -161,7 +183,7 @@ return {
161183
dap.defaults.fallback.exception_breakpoints = { 'Notice', 'Warning', 'Error', 'Exception' }
162184

163185
-- Install golang specific config
164-
require('dap-go').setup{
186+
require('dap-go').setup {
165187
delve = {
166188
detached = vim.fn.has 'win32' == 0,
167189
},

0 commit comments

Comments
 (0)