add devops and development profile
This commit is contained in:
1 parent
a0d2bcdfb0
commit
ab80f0d763
9 files changed
+128
-140
No files matched your search
@@ -99,6 +99,13 @@ function safe_require(name, setup, callback)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- ============================================================
|
||||||
|
-- PROFILE SWITCHES
|
||||||
|
-- Controls which LSPs, formatters and treesitter parsers are installed.
|
||||||
|
-- ============================================================
|
||||||
|
vim.g.load_devops = true -- Terraform, Nix, YAML, shell
|
||||||
|
vim.g.load_development = false -- Python, Kotlin, C/C++, LaTeX
|
||||||
|
|
||||||
require 'foundation'
|
require 'foundation'
|
||||||
|
|
||||||
require 'pack'
|
require 'pack'
|
||||||
@@ -106,7 +113,7 @@ require 'ui'
|
|||||||
require 'search'
|
require 'search'
|
||||||
require 'formatting'
|
require 'formatting'
|
||||||
require 'autocomplete'
|
require 'autocomplete'
|
||||||
require 'debugging'
|
|
||||||
require 'lsp'
|
require 'lsp'
|
||||||
|
require 'debugging'
|
||||||
require 'treesitter'
|
require 'treesitter'
|
||||||
require 'optional'
|
require 'optional'
|
||||||
@@ -10,7 +10,7 @@ do
|
|||||||
vim.pack.add { { src = gh 'L3MON4D3/LuaSnip', version = vim.version.range '2.*' } }
|
vim.pack.add { { src = gh 'L3MON4D3/LuaSnip', version = vim.version.range '2.*' } }
|
||||||
safe_require('luasnip', {}, function(luasnip)
|
safe_require('luasnip', {}, function(luasnip)
|
||||||
luasnip.config.setup { enable_autosnippets = true }
|
luasnip.config.setup { enable_autosnippets = true }
|
||||||
require('luasnip.loaders.from_lua').lazy_load { paths = { '~/.config/nvim/lua/snippets/' } }
|
require('luasnip.loaders.from_lua').lazy_load { paths = { vim.fn.stdpath 'config' .. '/lua/snippets/' } }
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- `friendly-snippets` contains a variety of premade snippets.
|
-- `friendly-snippets` contains a variety of premade snippets.
|
||||||
|
|||||||
+2
-5
@@ -96,11 +96,8 @@ do
|
|||||||
|
|
||||||
-- 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 = {
|
-- Debuggers only make sense with the development profile enabled
|
||||||
-- Update this to ensure that you have the debuggers for the langs you want
|
ensure_installed = vim.g.load_development and { 'python', 'kotlin' } or {},
|
||||||
'python',
|
|
||||||
'kotlin',
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Change breakpoint icons
|
-- Change breakpoint icons
|
||||||
|
|||||||
+23
-13
@@ -5,6 +5,28 @@
|
|||||||
do
|
do
|
||||||
-- [[ Formatting ]]
|
-- [[ Formatting ]]
|
||||||
vim.pack.add { gh 'stevearc/conform.nvim' }
|
vim.pack.add { gh 'stevearc/conform.nvim' }
|
||||||
|
|
||||||
|
-- Formatters are grouped by profile; see the switches in init.lua
|
||||||
|
local formatters_by_ft = {
|
||||||
|
bash = { 'shfmt' },
|
||||||
|
sh = { 'shfmt' },
|
||||||
|
zsh = { 'shfmt' },
|
||||||
|
lua = { 'stylua' },
|
||||||
|
}
|
||||||
|
|
||||||
|
if vim.g.load_devops then
|
||||||
|
formatters_by_ft.nix = { 'nixfmt' }
|
||||||
|
formatters_by_ft.terraform = { 'terraform_fmt' }
|
||||||
|
formatters_by_ft.yaml = { 'yamlfmt' }
|
||||||
|
end
|
||||||
|
|
||||||
|
if vim.g.load_development then
|
||||||
|
formatters_by_ft.python = { 'black', 'isort' }
|
||||||
|
formatters_by_ft.c = { 'clang-format' }
|
||||||
|
formatters_by_ft.cpp = { 'clang-format' }
|
||||||
|
formatters_by_ft.kotlin = { 'ktfmt' }
|
||||||
|
end
|
||||||
|
|
||||||
safe_require('conform', {
|
safe_require('conform', {
|
||||||
notify_on_error = true,
|
notify_on_error = true,
|
||||||
format_after_save = {
|
format_after_save = {
|
||||||
@@ -27,19 +49,7 @@ do
|
|||||||
lsp_format = 'fallback', -- Use external formatters if configured below, otherwise use LSP formatting. Set to `false` to disable LSP formatting entirely.
|
lsp_format = 'fallback', -- Use external formatters if configured below, otherwise use LSP formatting. Set to `false` to disable LSP formatting entirely.
|
||||||
},
|
},
|
||||||
-- You can also specify external formatters in here.
|
-- You can also specify external formatters in here.
|
||||||
formatters_by_ft = {
|
formatters_by_ft = formatters_by_ft,
|
||||||
bash = { 'shfmt' },
|
|
||||||
sh = { 'shfmt' },
|
|
||||||
zsh = { 'shfmt' },
|
|
||||||
python = { 'black', 'isort' },
|
|
||||||
lua = { 'stylua' },
|
|
||||||
c = { 'clang-format' },
|
|
||||||
cpp = { 'clang-format' },
|
|
||||||
kotlin = { 'ktfmt' },
|
|
||||||
--
|
|
||||||
-- You can use 'stop_after_first' to run the first available formatter from the list
|
|
||||||
-- javascript = { "prettierd", "prettier", stop_after_first = true },
|
|
||||||
},
|
|
||||||
}, function()
|
}, function()
|
||||||
vim.keymap.set({ 'n', 'v' }, '<leader>f', function() require('conform').format { async = true } end, { desc = '[F]ormat buffer' })
|
vim.keymap.set({ 'n', 'v' }, '<leader>f', function() require('conform').format { async = true } end, { desc = '[F]ormat buffer' })
|
||||||
end)
|
end)
|
||||||
|
|||||||
+8
-3
@@ -13,7 +13,7 @@ do
|
|||||||
vim.g.maplocalleader = ' '
|
vim.g.maplocalleader = ' '
|
||||||
|
|
||||||
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
||||||
vim.g.have_nerd_font = false
|
vim.g.have_nerd_font = true
|
||||||
|
|
||||||
-- [[ Setting options ]]
|
-- [[ Setting options ]]
|
||||||
-- See `:help vim.o`
|
-- See `:help vim.o`
|
||||||
@@ -34,9 +34,14 @@ do
|
|||||||
|
|
||||||
-- Sync clipboard between OS and Neovim.
|
-- Sync clipboard between OS and Neovim.
|
||||||
-- Schedule the setting after `UiEnter` because it can increase startup-time.
|
-- Schedule the setting after `UiEnter` because it can increase startup-time.
|
||||||
-- Remove this option if you want your OS clipboard to remain independent.
|
-- Only enable it when a clipboard tool exists (WSL needs win32yank.exe;
|
||||||
|
-- bare SSH sessions and containers usually have none).
|
||||||
-- See `:help 'clipboard'`
|
-- See `:help 'clipboard'`
|
||||||
vim.schedule(function() vim.o.clipboard = 'unnamedplus' end)
|
vim.schedule(function()
|
||||||
|
local tools = { 'win32yank.exe', 'wl-copy', 'xclip', 'xsel' }
|
||||||
|
local has_tool = vim.iter(tools):any(function(tool) return vim.fn.executable(tool) == 1 end)
|
||||||
|
vim.o.clipboard = has_tool and 'unnamedplus' or ''
|
||||||
|
end)
|
||||||
|
|
||||||
-- Enable break indent
|
-- Enable break indent
|
||||||
vim.o.breakindent = true
|
vim.o.breakindent = true
|
||||||
|
|||||||
+65
-86
@@ -114,98 +114,23 @@ do
|
|||||||
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
||||||
-- See `:help lsp-config` for information about keys and how to configure
|
-- See `:help lsp-config` for information about keys and how to configure
|
||||||
local formatters_and_tools = {
|
local formatters_and_tools = {
|
||||||
'clang-format', -- Using the correct hyphen!
|
|
||||||
'isort',
|
|
||||||
'ktfmt',
|
|
||||||
'nixfmt',
|
|
||||||
'shfmt',
|
'shfmt',
|
||||||
'stylua',
|
'stylua',
|
||||||
'black',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if vim.g.load_devops then vim.list_extend(formatters_and_tools, { 'nixfmt', 'terraform', 'yamlfmt' }) end
|
||||||
|
|
||||||
|
if vim.g.load_development then vim.list_extend(formatters_and_tools, { 'black', 'isort', 'clang-format', 'ktfmt' }) end
|
||||||
|
|
||||||
|
-- Servers that apply regardless of profile
|
||||||
---@type table<string, vim.lsp.Config>
|
---@type table<string, vim.lsp.Config>
|
||||||
local servers = {
|
local servers = {
|
||||||
-- json
|
-- json
|
||||||
jsonls = {},
|
jsonls = {},
|
||||||
-- terraform
|
-- bash / sh
|
||||||
terraformls = {},
|
|
||||||
-- c
|
|
||||||
clangd = {
|
|
||||||
cmd = {
|
|
||||||
'clangd',
|
|
||||||
'--background-index',
|
|
||||||
'--clang-tidy',
|
|
||||||
'--query-driver=/nix/store/*/bin/*gcc*',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
neocmake = {},
|
|
||||||
-- nix
|
|
||||||
nil_ls = {},
|
|
||||||
-- python
|
|
||||||
-- pylsp = {
|
|
||||||
-- -- plugins = {
|
|
||||||
-- -- -- formatter options
|
|
||||||
-- -- black = { enabled = true },
|
|
||||||
-- -- autopep8 = { enabled = false },
|
|
||||||
-- -- yapf = { enabled = false },
|
|
||||||
-- -- -- linter options
|
|
||||||
-- -- pylint = { enabled = true, executable = 'pylint' },
|
|
||||||
-- -- pyflakes = { enabled = false },
|
|
||||||
-- -- pycodestyle = { enabled = false },
|
|
||||||
-- -- -- type checker
|
|
||||||
-- -- pylsp_mypy = { enabled = true },
|
|
||||||
-- -- -- auto-completion options
|
|
||||||
-- -- jedi_completion = { fuzzy = true },
|
|
||||||
-- -- -- import sorting
|
|
||||||
-- -- pyls_isort = { enabled = true },
|
|
||||||
-- -- },
|
|
||||||
-- },
|
|
||||||
pyright = {},
|
|
||||||
ruff = {},
|
|
||||||
isort = {},
|
|
||||||
-- kotlin
|
|
||||||
kotlin_lsp = {},
|
|
||||||
-- latex
|
|
||||||
texlab = {},
|
|
||||||
-- bash
|
|
||||||
bashls = {},
|
bashls = {},
|
||||||
-- markdown
|
-- markdown / prose
|
||||||
markdown_oxide = {},
|
markdown_oxide = {},
|
||||||
kakehashi = {
|
|
||||||
filetypes = { 'markdown' },
|
|
||||||
init_options = {
|
|
||||||
languageServers = {
|
|
||||||
['texlab'] = {
|
|
||||||
cmd = { 'texlab' },
|
|
||||||
languages = { 'latex' },
|
|
||||||
},
|
|
||||||
['lua_ls'] = {
|
|
||||||
cmd = { 'lua-language-server' },
|
|
||||||
languages = { 'lua' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
languages = {
|
|
||||||
_ = {
|
|
||||||
autoInstall = true,
|
|
||||||
},
|
|
||||||
markdown = {
|
|
||||||
bridge = {
|
|
||||||
texlab = { enabled = true },
|
|
||||||
lua_ls = { enabled = true },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
-- gopls = {},
|
|
||||||
-- pyright = {},
|
|
||||||
-- rust_analyzer = {},
|
|
||||||
--
|
|
||||||
-- Some languages (like typescript) have entire language plugins that can be useful:
|
|
||||||
-- https://github.com/pmizio/typescript-tools.nvim
|
|
||||||
--
|
|
||||||
-- But for many setups, the LSP (`ts_ls`) will work just fine
|
|
||||||
-- ts_ls = {},
|
|
||||||
|
|
||||||
-- Special Lua Config, as recommended by neovim help docs
|
-- Special Lua Config, as recommended by neovim help docs
|
||||||
lua_ls = {
|
lua_ls = {
|
||||||
@@ -242,6 +167,62 @@ do
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Infrastructure / DevOps profile
|
||||||
|
if vim.g.load_devops then
|
||||||
|
-- terraform
|
||||||
|
servers.terraformls = {}
|
||||||
|
-- nix
|
||||||
|
servers.nil_ls = {}
|
||||||
|
-- yaml
|
||||||
|
servers.yamlls = {
|
||||||
|
settings = {
|
||||||
|
yaml = {
|
||||||
|
schemaStore = { enable = true },
|
||||||
|
validate = true,
|
||||||
|
format = { enable = false }, -- formatting is handled by conform
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- General development profile
|
||||||
|
if vim.g.load_development then
|
||||||
|
servers.clangd = {
|
||||||
|
cmd = { 'clangd', '--background-index', '--clang-tidy' },
|
||||||
|
}
|
||||||
|
servers.neocmake = {}
|
||||||
|
servers.pyright = {}
|
||||||
|
servers.ruff = {}
|
||||||
|
servers.kotlin_lsp = {}
|
||||||
|
servers.texlab = {}
|
||||||
|
servers.kakehashi = {
|
||||||
|
filetypes = { 'markdown' },
|
||||||
|
init_options = {
|
||||||
|
languageServers = {
|
||||||
|
['texlab'] = {
|
||||||
|
cmd = { 'texlab' },
|
||||||
|
languages = { 'latex' },
|
||||||
|
},
|
||||||
|
['lua_ls'] = {
|
||||||
|
cmd = { 'lua-language-server' },
|
||||||
|
languages = { 'lua' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
languages = {
|
||||||
|
_ = {
|
||||||
|
autoInstall = true,
|
||||||
|
},
|
||||||
|
markdown = {
|
||||||
|
bridge = {
|
||||||
|
texlab = { enabled = true },
|
||||||
|
lua_ls = { enabled = true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
vim.pack.add {
|
vim.pack.add {
|
||||||
gh 'neovim/nvim-lspconfig',
|
gh 'neovim/nvim-lspconfig',
|
||||||
gh 'mason-org/mason.nvim',
|
gh 'mason-org/mason.nvim',
|
||||||
@@ -262,7 +243,7 @@ do
|
|||||||
local ensure_installed = vim.tbl_keys(servers or {})
|
local ensure_installed = vim.tbl_keys(servers or {})
|
||||||
vim.list_extend(ensure_installed, formatters_and_tools)
|
vim.list_extend(ensure_installed, formatters_and_tools)
|
||||||
|
|
||||||
safe_require('mason-tool-installer', { ensure_installed = ensure_installed, auto_update = true, run_on_start = true }, function(_)
|
safe_require('mason-tool-installer', { ensure_installed = ensure_installed, auto_update = false, run_on_start = true }, function(_)
|
||||||
-- for name in ensure_installed do
|
-- for name in ensure_installed do
|
||||||
-- vim.lsp.enable(name)
|
-- vim.lsp.enable(name)
|
||||||
-- end
|
-- end
|
||||||
@@ -272,6 +253,4 @@ do
|
|||||||
vim.lsp.enable(name)
|
vim.lsp.enable(name)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
vim.diagnostic.config { update_in_insert = true }
|
|
||||||
end
|
end
|
||||||
@@ -54,12 +54,6 @@ do
|
|||||||
if vim.fn.has 'win32' ~= 1 and vim.fn.executable 'make' == 1 then run_build(name, { 'make', 'install_jsregexp' }, ev.data.path) end
|
if vim.fn.has 'win32' ~= 1 and vim.fn.executable 'make' == 1 then run_build(name, { 'make', 'install_jsregexp' }, ev.data.path) end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if name == 'nvim-treesitter' then
|
|
||||||
if not ev.data.active then vim.cmd.packadd 'nvim-treesitter' end
|
|
||||||
vim.cmd 'TSUpdate'
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
+21
-24
@@ -4,31 +4,28 @@
|
|||||||
-- ============================================================
|
-- ============================================================
|
||||||
do
|
do
|
||||||
vim.pack.add { { src = gh 'romus204/tree-sitter-manager.nvim' } }
|
vim.pack.add { { src = gh 'romus204/tree-sitter-manager.nvim' } }
|
||||||
|
|
||||||
|
-- Parsers are grouped by profile; see the switches in init.lua
|
||||||
|
local parsers = {
|
||||||
|
'bash',
|
||||||
|
'dockerfile',
|
||||||
|
'gitignore',
|
||||||
|
'json',
|
||||||
|
'lua',
|
||||||
|
'markdown',
|
||||||
|
'markdown_inline',
|
||||||
|
'query',
|
||||||
|
'vim',
|
||||||
|
'vimdoc',
|
||||||
|
'yaml',
|
||||||
|
}
|
||||||
|
|
||||||
|
if vim.g.load_devops then vim.list_extend(parsers, { 'hcl', 'nix' }) end
|
||||||
|
|
||||||
|
if vim.g.load_development then vim.list_extend(parsers, { 'c', 'css', 'go', 'html', 'java', 'javascript', 'kotlin', 'latex', 'python', 'sql', 'typst' }) end
|
||||||
|
|
||||||
safe_require('tree-sitter-manager', {
|
safe_require('tree-sitter-manager', {
|
||||||
ensure_installed = {
|
ensure_installed = parsers,
|
||||||
'bash',
|
|
||||||
'c',
|
|
||||||
'css',
|
|
||||||
'dockerfile',
|
|
||||||
'gitignore',
|
|
||||||
'go',
|
|
||||||
'html',
|
|
||||||
'java',
|
|
||||||
'javascript',
|
|
||||||
'json',
|
|
||||||
'kotlin',
|
|
||||||
'latex',
|
|
||||||
'lua',
|
|
||||||
'markdown',
|
|
||||||
'markdown_inline',
|
|
||||||
'python',
|
|
||||||
'query',
|
|
||||||
'sql',
|
|
||||||
'typst',
|
|
||||||
'yaml',
|
|
||||||
'vim',
|
|
||||||
'vimdoc',
|
|
||||||
},
|
|
||||||
sync_install = false,
|
sync_install = false,
|
||||||
auto_install = true,
|
auto_install = true,
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ do
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- Useful plugin to show you pending keybinds.
|
-- Useful plugin to show you pending keybinds.
|
||||||
vim.pack.add { gh 'nvim-tree/nvim-web-devicons' }
|
|
||||||
vim.pack.add { gh 'folke/which-key.nvim' }
|
vim.pack.add { gh 'folke/which-key.nvim' }
|
||||||
safe_require('which-key', {
|
safe_require('which-key', {
|
||||||
-- Delay between pressing a key and opening which-key (milliseconds)
|
-- Delay between pressing a key and opening which-key (milliseconds)
|
||||||
|
|||||||
Reference in new issue
Block a user