harden language tooling setup
This commit is contained in:
parent
48ba60ab70
commit
20fd850084
130
init.lua
130
init.lua
|
|
@ -124,6 +124,26 @@ vim.o.shiftwidth = 2
|
||||||
vim.o.softtabstop = 2
|
vim.o.softtabstop = 2
|
||||||
vim.o.expandtab = true
|
vim.o.expandtab = true
|
||||||
|
|
||||||
|
vim.filetype.add {
|
||||||
|
extension = {
|
||||||
|
mdx = 'mdx',
|
||||||
|
},
|
||||||
|
filename = {
|
||||||
|
['compose.yaml'] = 'yaml.docker-compose',
|
||||||
|
['compose.yml'] = 'yaml.docker-compose',
|
||||||
|
['docker-compose.yaml'] = 'yaml.docker-compose',
|
||||||
|
['docker-compose.yml'] = 'yaml.docker-compose',
|
||||||
|
['.gitlab-ci.yaml'] = 'yaml.gitlab',
|
||||||
|
['.gitlab-ci.yml'] = 'yaml.gitlab',
|
||||||
|
},
|
||||||
|
pattern = {
|
||||||
|
['.*/templates/.*%.yaml'] = 'helm',
|
||||||
|
['.*/templates/.*%.yml'] = 'helm',
|
||||||
|
['.*/values.*%.yaml'] = 'yaml.helm-values',
|
||||||
|
['.*/values.*%.yml'] = 'yaml.helm-values',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
-- Enable undo/redo changes even after closing and reopening a file
|
-- Enable undo/redo changes even after closing and reopening a file
|
||||||
vim.o.undofile = true
|
vim.o.undofile = true
|
||||||
|
|
||||||
|
|
@ -331,6 +351,20 @@ end
|
||||||
local rtp = vim.opt.rtp
|
local rtp = vim.opt.rtp
|
||||||
rtp:prepend(lazypath)
|
rtp:prepend(lazypath)
|
||||||
|
|
||||||
|
local treesitter_parsers = {
|
||||||
|
'bash',
|
||||||
|
'c',
|
||||||
|
'diff',
|
||||||
|
'html',
|
||||||
|
'lua',
|
||||||
|
'luadoc',
|
||||||
|
'markdown',
|
||||||
|
'markdown_inline',
|
||||||
|
'query',
|
||||||
|
'vim',
|
||||||
|
'vimdoc',
|
||||||
|
}
|
||||||
|
|
||||||
-- [[ Configure and install plugins ]]
|
-- [[ Configure and install plugins ]]
|
||||||
--
|
--
|
||||||
-- To check the current status of your plugins, run
|
-- To check the current status of your plugins, run
|
||||||
|
|
@ -396,7 +430,6 @@ require('lazy').setup({
|
||||||
{ '<leader>G', group = '[G]it' },
|
{ '<leader>G', group = '[G]it' },
|
||||||
{ '<leader>m', group = '[M]arkdown' },
|
{ '<leader>m', group = '[M]arkdown' },
|
||||||
{ '<leader>n', group = '[N]eotest' },
|
{ '<leader>n', group = '[N]eotest' },
|
||||||
{ '<leader>o', group = '[O]pencode' },
|
|
||||||
{ '<leader>s', group = '[S]earch' },
|
{ '<leader>s', group = '[S]earch' },
|
||||||
{ '<leader>t', group = '[T]oggle' },
|
{ '<leader>t', group = '[T]oggle' },
|
||||||
{ '<leader>w', group = '[W]indow' },
|
{ '<leader>w', group = '[W]indow' },
|
||||||
|
|
@ -768,22 +801,11 @@ require('lazy').setup({
|
||||||
languages = { 'vue' },
|
languages = { 'vue' },
|
||||||
configNamespace = 'typescript',
|
configNamespace = 'typescript',
|
||||||
}
|
}
|
||||||
|
local has_go = vim.fn.executable 'go' == 1
|
||||||
|
|
||||||
local servers = {
|
local servers = {
|
||||||
-- Languages
|
-- Languages
|
||||||
clangd = {},
|
clangd = {},
|
||||||
gopls = {
|
|
||||||
settings = {
|
|
||||||
gopls = {
|
|
||||||
analyses = {
|
|
||||||
unusedparams = true,
|
|
||||||
shadow = true,
|
|
||||||
},
|
|
||||||
staticcheck = true,
|
|
||||||
gofumpt = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
basedpyright = {
|
basedpyright = {
|
||||||
settings = {
|
settings = {
|
||||||
basedpyright = {
|
basedpyright = {
|
||||||
|
|
@ -821,7 +843,6 @@ require('lazy').setup({
|
||||||
taplo = {},
|
taplo = {},
|
||||||
elixirls = {},
|
elixirls = {},
|
||||||
gh_actions_ls = {},
|
gh_actions_ls = {},
|
||||||
jqls = {},
|
|
||||||
lua_ls = {
|
lua_ls = {
|
||||||
-- cmd = { ... },
|
-- cmd = { ... },
|
||||||
-- filetypes = { ... },
|
-- filetypes = { ... },
|
||||||
|
|
@ -863,6 +884,44 @@ require('lazy').setup({
|
||||||
-- But for many setups, the LSP (`ts_ls`) will work just fine
|
-- But for many setups, the LSP (`ts_ls`) will work just fine
|
||||||
--
|
--
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if has_go then
|
||||||
|
servers.gopls = {
|
||||||
|
settings = {
|
||||||
|
gopls = {
|
||||||
|
analyses = {
|
||||||
|
unusedparams = true,
|
||||||
|
shadow = true,
|
||||||
|
},
|
||||||
|
staticcheck = true,
|
||||||
|
gofumpt = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
if vim.fn.executable 'jq-lsp' == 1 then
|
||||||
|
servers.jqls = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
servers.marksman.filetypes = { 'markdown', 'mdx' }
|
||||||
|
servers.tailwindcss.filetypes = {
|
||||||
|
'astro',
|
||||||
|
'css',
|
||||||
|
'html',
|
||||||
|
'javascript',
|
||||||
|
'javascriptreact',
|
||||||
|
'less',
|
||||||
|
'markdown',
|
||||||
|
'mdx',
|
||||||
|
'sass',
|
||||||
|
'scss',
|
||||||
|
'svelte',
|
||||||
|
'typescript',
|
||||||
|
'typescriptreact',
|
||||||
|
'vue',
|
||||||
|
}
|
||||||
|
|
||||||
---@type MasonLspconfigSettings
|
---@type MasonLspconfigSettings
|
||||||
---@diagnostic disable-next-line: missing-fields
|
---@diagnostic disable-next-line: missing-fields
|
||||||
require('mason-lspconfig').setup {
|
require('mason-lspconfig').setup {
|
||||||
|
|
@ -876,7 +935,9 @@ require('lazy').setup({
|
||||||
-- :Mason
|
-- :Mason
|
||||||
--
|
--
|
||||||
-- You can press `g?` for help in this menu.
|
-- You can press `g?` for help in this menu.
|
||||||
local ensure_installed = vim.tbl_keys(servers or {})
|
local ensure_installed = vim.tbl_filter(function(server_name)
|
||||||
|
return server_name ~= 'gopls' and server_name ~= 'jqls'
|
||||||
|
end, vim.tbl_keys(servers or {}))
|
||||||
vim.list_extend(ensure_installed, {
|
vim.list_extend(ensure_installed, {
|
||||||
'stylua', -- Used to format Lua code
|
'stylua', -- Used to format Lua code
|
||||||
'markdownlint', -- Used by nvim-lint for Markdown buffers
|
'markdownlint', -- Used by nvim-lint for Markdown buffers
|
||||||
|
|
@ -1125,26 +1186,30 @@ require('lazy').setup({
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
branch = 'main',
|
branch = 'main',
|
||||||
lazy = false,
|
lazy = false,
|
||||||
lazy = false,
|
build = function()
|
||||||
build = ':TSUpdate',
|
if vim.fn.executable 'tree-sitter' ~= 1 then
|
||||||
|
vim.notify('nvim-treesitter: tree-sitter CLI is required to install parsers', vim.log.levels.WARN)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local ok, treesitter = pcall(require, 'nvim-treesitter')
|
||||||
|
if ok then
|
||||||
|
treesitter.install(treesitter_parsers, { summary = true }):wait(300000)
|
||||||
|
end
|
||||||
|
end,
|
||||||
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
||||||
config = function()
|
config = function()
|
||||||
local treesitter = require 'nvim-treesitter'
|
local treesitter = require 'nvim-treesitter'
|
||||||
treesitter.setup {
|
treesitter.setup()
|
||||||
ensure_installed = {
|
|
||||||
'bash',
|
vim.api.nvim_create_user_command('TSInstallConfigured', function()
|
||||||
'c',
|
if vim.fn.executable 'tree-sitter' ~= 1 then
|
||||||
'diff',
|
vim.notify('nvim-treesitter: install tree-sitter CLI first', vim.log.levels.ERROR)
|
||||||
'html',
|
return
|
||||||
'lua',
|
end
|
||||||
'luadoc',
|
|
||||||
'markdown',
|
treesitter.install(treesitter_parsers, { summary = true }):raise_on_error()
|
||||||
'markdown_inline',
|
end, { desc = 'Install configured Treesitter parsers' })
|
||||||
'query',
|
|
||||||
'vim',
|
|
||||||
'vimdoc',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('FileType', {
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
group = vim.api.nvim_create_augroup('kickstart-treesitter', { clear = true }),
|
group = vim.api.nvim_create_augroup('kickstart-treesitter', { clear = true }),
|
||||||
|
|
@ -1176,6 +1241,7 @@ require('lazy').setup({
|
||||||
-- In normal mode type `<space>sh` then write `lazy.nvim-plugin`
|
-- In normal mode type `<space>sh` then write `lazy.nvim-plugin`
|
||||||
-- you can continue same window with `<space>sr` which resumes last telescope search
|
-- you can continue same window with `<space>sr` which resumes last telescope search
|
||||||
}, { ---@diagnostic disable-line: missing-fields
|
}, { ---@diagnostic disable-line: missing-fields
|
||||||
|
rocks = { enabled = false },
|
||||||
ui = {
|
ui = {
|
||||||
-- If you are using a Nerd Font: set icons to an empty table which will use the
|
-- If you are using a Nerd Font: set icons to an empty table which will use the
|
||||||
-- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table
|
-- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ return {
|
||||||
config = function()
|
config = function()
|
||||||
local dap = require 'dap'
|
local dap = require 'dap'
|
||||||
local dapui = require 'dapui'
|
local dapui = require 'dapui'
|
||||||
|
local has_delve = vim.fn.executable 'dlv' == 1
|
||||||
|
|
||||||
require('mason-nvim-dap').setup {
|
require('mason-nvim-dap').setup {
|
||||||
-- Makes a best effort to setup the various debuggers with
|
-- Makes a best effort to setup the various debuggers with
|
||||||
|
|
@ -90,11 +91,7 @@ return {
|
||||||
|
|
||||||
-- You'll need to check that you have the required things installed
|
-- You'll need to check that you have the required things installed
|
||||||
-- online, please don't ask me how to install them :)
|
-- online, please don't ask me how to install them :)
|
||||||
ensure_installed = {
|
ensure_installed = { 'codelldb' },
|
||||||
-- Update this to ensure that you have the debuggers for the langs you want
|
|
||||||
'delve',
|
|
||||||
'codelldb',
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Dap UI setup
|
-- Dap UI setup
|
||||||
|
|
@ -137,14 +134,15 @@ return {
|
||||||
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
|
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
|
||||||
dap.listeners.before.event_exited['dapui_config'] = dapui.close
|
dap.listeners.before.event_exited['dapui_config'] = dapui.close
|
||||||
|
|
||||||
-- Install golang specific config
|
if has_delve then
|
||||||
require('dap-go').setup {
|
require('dap-go').setup {
|
||||||
delve = {
|
delve = {
|
||||||
-- On Windows delve must be run attached or it crashes.
|
-- On Windows delve must be run attached or it crashes.
|
||||||
-- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring
|
-- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring
|
||||||
detached = vim.fn.has 'win32' == 0,
|
detached = vim.fn.has 'win32' == 0,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
||||||
setup_cpp_dap(dap)
|
setup_cpp_dap(dap)
|
||||||
end,
|
end,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,12 @@
|
||||||
return {
|
return {
|
||||||
'pmizio/typescript-tools.nvim',
|
'pmizio/typescript-tools.nvim',
|
||||||
dependencies = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' },
|
dependencies = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' },
|
||||||
opts = {},
|
opts = {
|
||||||
|
filetypes = {
|
||||||
|
'javascript',
|
||||||
|
'javascriptreact',
|
||||||
|
'typescript',
|
||||||
|
'typescriptreact',
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue