nvim: refactor config
This commit is contained in:
parent
225b1b37f2
commit
61578424eb
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
|
||||
"LuaSnip": { "branch": "master", "commit": "8ae1dedd988eb56441b7858bd1e8554dfadaa46d" },
|
||||
"bufferline.nvim": { "branch": "main", "commit": "6c456b888823d9e4832aa91c482bccd19445c009" },
|
||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||
"cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
|
||||
|
@ -15,19 +14,19 @@
|
|||
"lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "3ba1b92b771f33256b4969d696b82c8ae7075364" },
|
||||
"mason-nvim-dap.nvim": { "branch": "main", "commit": "3614a39aae98ccd34124b072939d6283853b3dd2" },
|
||||
"mason.nvim": { "branch": "main", "commit": "bce96d2fd483e71826728c6f9ac721fc9dd7d2cf" },
|
||||
"mason.nvim": { "branch": "main", "commit": "9c9416817c9f4e6f333c749327a1ed5355cfab61" },
|
||||
"neo-tree.nvim": { "branch": "v3.x", "commit": "2f2d08894bbc679d4d181604c16bb7079f646384" },
|
||||
"neodev.nvim": { "branch": "main", "commit": "aaeb44589cab39c2545a328661af355622d68479" },
|
||||
"neodev.nvim": { "branch": "main", "commit": "5bbbeda6a9c672f314c95ca47a8b495cf6de17f9" },
|
||||
"nui.nvim": { "branch": "main", "commit": "35da9ca1de0fc4dda96c2e214d93d363c145f418" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" },
|
||||
"nvim-dap": { "branch": "master", "commit": "9adbfdca13afbe646d09a8d7a86d5d031fb9c5a5" },
|
||||
"nvim-dap-ui": { "branch": "master", "commit": "a62e86b124a94ad1f34a3f936ea146d00aa096d1" },
|
||||
"nvim-dap-ui": { "branch": "master", "commit": "d845ebd798ad1cf30aa4abd4c4eff795cdcfdd4f" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "8917d2c830e04bf944a699b8c41f097621283828" },
|
||||
"nvim-notify": { "branch": "master", "commit": "80b67b265530632505193553d05127ae7fe09ddd" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "94bd4bcc5bbce8334303727627b628ece72e798d" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "cd4e0909948eb33d3959e133c16f837e4db122c6" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "140edfcf25093e8b321d13e154cbce89ee868ca0" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "663246936325062427597964d81d30eaa42ab1e4" },
|
||||
"rustaceanvim": { "branch": "master", "commit": "b0c03f052d24a2bfc4cc681075c2d81d3c3ac2f7" },
|
||||
"rustaceanvim": { "branch": "master", "commit": "a095a1f9397310d108ead239edc068b2624695b6" },
|
||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
|
||||
"telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }
|
||||
|
|
38
nvim/lua/config/composer.lua
Normal file
38
nvim/lua/config/composer.lua
Normal file
|
@ -0,0 +1,38 @@
|
|||
---@alias Tag
|
||||
--- | 'standalone'
|
||||
--- | 'linux'
|
||||
|
||||
---@type table<Tag, boolean>
|
||||
local env = {
|
||||
standalone = not vim.g.vscode,
|
||||
linux = jit.os == 'Linux',
|
||||
}
|
||||
|
||||
---@param tags Tag | Tag[]
|
||||
local function is(tags)
|
||||
if type(tags) == 'string' then
|
||||
return env[tags] or false
|
||||
end
|
||||
|
||||
for _, tag in ipairs(tags) do
|
||||
if not env[tag] then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
---@param tags Tag | Tag[]
|
||||
local function when(tags)
|
||||
local match = is(tags)
|
||||
---@generic T
|
||||
---@param table `T`
|
||||
---@return T | nil
|
||||
return function(table)
|
||||
return match and table or nil
|
||||
end
|
||||
end
|
||||
|
||||
return function()
|
||||
return is, when
|
||||
end
|
|
@ -16,7 +16,7 @@ end
|
|||
vim.opt.rtp:prepend(path)
|
||||
|
||||
-- Load
|
||||
local plugins = require 'plugins'
|
||||
local plugins = require 'config.plugins'
|
||||
local lazy = require 'lazy'
|
||||
|
||||
-- Init
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
local is, when = require 'config.composer' ()
|
||||
local util = require 'config.utils'
|
||||
local n = util.keymap 'n'
|
||||
|
||||
|
@ -8,7 +9,7 @@ return {
|
|||
-- Theme
|
||||
{
|
||||
'rebelot/kanagawa.nvim',
|
||||
enabled = not vim.g.vscode,
|
||||
enabled = is 'standalone',
|
||||
lazy = false,
|
||||
priority = math.huge,
|
||||
config = function()
|
||||
|
@ -19,32 +20,38 @@ return {
|
|||
-- Status line
|
||||
{
|
||||
'nvim-lualine/lualine.nvim',
|
||||
enabled = not vim.g.vscode,
|
||||
enabled = is 'standalone',
|
||||
dependencies = {
|
||||
'nvim-tree/nvim-web-devicons',
|
||||
},
|
||||
config = function()
|
||||
local lualine = require 'lualine'
|
||||
lualine.setup {}
|
||||
|
||||
lualine.setup {
|
||||
tabline = {
|
||||
lualine_a = { 'buffers' },
|
||||
}
|
||||
}
|
||||
end
|
||||
},
|
||||
|
||||
-- Telescope
|
||||
{
|
||||
'nvim-telescope/telescope.nvim',
|
||||
enabled = not vim.g.vscode,
|
||||
enabled = is 'standalone',
|
||||
branch = '0.1.x',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }
|
||||
when 'linux' { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }
|
||||
},
|
||||
config = function()
|
||||
local telescope = require 'telescope'
|
||||
local builtin = require 'telescope.builtin'
|
||||
local ext = telescope.extensions
|
||||
|
||||
telescope.load_extension 'fzf'
|
||||
telescope.load_extension 'notify'
|
||||
if is 'linux' then telescope.load_extension 'fzf' end
|
||||
if is 'standalone' then telescope.load_extension 'notify' end
|
||||
|
||||
telescope.setup {
|
||||
extensions = {
|
||||
fzf = {
|
||||
|
@ -60,7 +67,10 @@ return {
|
|||
n '<leader>fb' (builtin.buffers) 'Telescope: find buffers'
|
||||
n '<leader>fg' (builtin.live_grep) 'Telescope: grep content'
|
||||
n '<leader>fh' (builtin.help_tags) 'Telescope: search docs'
|
||||
|
||||
if is 'standalone' then
|
||||
n '<leader>fn' (ext.notify.notify) 'Telescope: find notifications'
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
||||
|
@ -80,7 +90,7 @@ return {
|
|||
-- neovim
|
||||
'vimdoc', 'lua', 'query',
|
||||
-- data
|
||||
'json', 'xml', 'yaml', 'toml', 'dhall',
|
||||
'json', 'xml', 'yaml', 'toml',
|
||||
-- markdown
|
||||
'markdown', 'markdown_inline',
|
||||
-- latex
|
||||
|
@ -91,8 +101,6 @@ return {
|
|||
'comment', 'dockerfile', 'regex',
|
||||
-- shell
|
||||
'bash',
|
||||
-- julia
|
||||
'julia',
|
||||
-- python
|
||||
'python',
|
||||
-- rust
|
||||
|
@ -100,7 +108,7 @@ return {
|
|||
-- webdev
|
||||
'html', 'css', 'scss', 'javascript', 'jsdoc', 'typescript', 'tsx', 'astro', 'svelte',
|
||||
-- haskell
|
||||
'haskell', 'purescript', 'nix',
|
||||
'haskell',
|
||||
},
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
|
@ -126,11 +134,8 @@ return {
|
|||
-- Git signs
|
||||
{
|
||||
'lewis6991/gitsigns.nvim',
|
||||
enabled = not vim.g.vscode,
|
||||
config = function()
|
||||
local gitsigns = require 'gitsigns'
|
||||
gitsigns.setup()
|
||||
end,
|
||||
enabled = is 'standalone',
|
||||
config = true,
|
||||
},
|
||||
|
||||
-- Comments
|
||||
|
@ -142,7 +147,7 @@ return {
|
|||
-- Shortcut hints
|
||||
{
|
||||
'folke/which-key.nvim',
|
||||
enabled = not vim.g.vscode,
|
||||
enabled = is 'standalone',
|
||||
event = 'VeryLazy',
|
||||
init = function()
|
||||
vim.o.timeout = true
|
||||
|
@ -154,7 +159,7 @@ return {
|
|||
-- Notifications
|
||||
{
|
||||
'rcarriga/nvim-notify',
|
||||
enabled = not vim.g.vscode,
|
||||
enabled = is 'standalone',
|
||||
config = function()
|
||||
vim.notify = require 'notify'
|
||||
end
|
||||
|
@ -163,7 +168,7 @@ return {
|
|||
-- File tree
|
||||
{
|
||||
'nvim-neo-tree/neo-tree.nvim',
|
||||
enabled = not vim.g.vscode,
|
||||
enabled = is 'standalone',
|
||||
branch = 'v3.x',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
|
@ -172,44 +177,16 @@ return {
|
|||
},
|
||||
},
|
||||
|
||||
-- Bufferline
|
||||
{
|
||||
'akinsho/bufferline.nvim',
|
||||
enabled = not vim.g.vscode,
|
||||
version = '*',
|
||||
dependencies = {
|
||||
'nvim-tree/nvim-web-devicons'
|
||||
},
|
||||
config = function()
|
||||
local config = require 'bufferline'
|
||||
config.setup()
|
||||
end
|
||||
},
|
||||
|
||||
-- Git diffviewer
|
||||
{
|
||||
'sindrets/diffview.nvim',
|
||||
enabled = not vim.g.vscode,
|
||||
enabled = is 'standalone',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
'nvim-tree/nvim-web-devicons',
|
||||
},
|
||||
},
|
||||
|
||||
-- LS configs
|
||||
{
|
||||
'neovim/nvim-lspconfig',
|
||||
enabled = not vim.g.vscode,
|
||||
opts = {
|
||||
inlay_hints = { enabled = true },
|
||||
},
|
||||
config = function()
|
||||
local lsp = require 'lspconfig'
|
||||
|
||||
lsp.nushell.setup {}
|
||||
end,
|
||||
},
|
||||
|
||||
-- Snippet engine
|
||||
{
|
||||
'L3MON4D3/LuaSnip',
|
||||
|
@ -228,10 +205,16 @@ return {
|
|||
},
|
||||
},
|
||||
|
||||
-- LS configs
|
||||
{
|
||||
'neovim/nvim-lspconfig',
|
||||
enabled = is { 'standalone', 'linux' },
|
||||
},
|
||||
|
||||
-- Debugger adapter support
|
||||
{
|
||||
'mfussenegger/nvim-dap',
|
||||
enabled = not vim.g.vscode,
|
||||
enabled = is { 'standalone', 'linux' },
|
||||
config = function()
|
||||
local dap = require 'dap'
|
||||
|
||||
|
@ -242,7 +225,7 @@ return {
|
|||
-- Debugger UI
|
||||
require 'plugins.nvim-dap-ui' {
|
||||
'rcarriga/nvim-dap-ui',
|
||||
enabled = not vim.g.vscode,
|
||||
enabled = is { 'standalone', 'linux' },
|
||||
dependencies = {
|
||||
'mfussenegger/nvim-dap',
|
||||
},
|
||||
|
@ -251,17 +234,14 @@ return {
|
|||
-- Mason
|
||||
{
|
||||
'williamboman/mason.nvim',
|
||||
enabled = not vim.g.vscode,
|
||||
config = function()
|
||||
local mason = require 'mason'
|
||||
mason.setup()
|
||||
end,
|
||||
enabled = is { 'standalone', 'linux' },
|
||||
config = true,
|
||||
},
|
||||
|
||||
-- Automatic LSP server setup for Mason
|
||||
{
|
||||
'williamboman/mason-lspconfig.nvim',
|
||||
enabled = not vim.g.vscode,
|
||||
enabled = is { 'standalone', 'linux' },
|
||||
dependencies = {
|
||||
'williamboman/mason.nvim',
|
||||
'neovim/nvim-lspconfig',
|
||||
|
@ -309,7 +289,7 @@ return {
|
|||
-- Automatic debugger install
|
||||
{
|
||||
'jay-babu/mason-nvim-dap.nvim',
|
||||
enabled = not vim.g.vscode,
|
||||
enabled = is { 'standalone', 'linux' },
|
||||
dependencies = {
|
||||
'mfussenegger/nvim-dap',
|
||||
'williamboman/mason.nvim',
|
||||
|
@ -329,7 +309,7 @@ return {
|
|||
-- Tools for Neovim
|
||||
{
|
||||
'folke/neodev.nvim',
|
||||
enabled = not vim.g.vscode,
|
||||
enabled = is { 'standalone', 'linux' },
|
||||
ft = 'lua',
|
||||
dependencies = {
|
||||
'neovim/nvim-lspconfig',
|
||||
|
@ -350,7 +330,7 @@ return {
|
|||
-- Tools for Rust
|
||||
{
|
||||
'mrcjkb/rustaceanvim',
|
||||
enabled = not vim.g.vscode,
|
||||
enabled = is { 'standalone', 'linux' },
|
||||
version = '^3',
|
||||
ft = { 'rust' },
|
||||
init = function()
|
||||
|
@ -361,7 +341,7 @@ return {
|
|||
-- Tools for Haskell
|
||||
require 'plugins.haskell-tools' {
|
||||
'mrcjkb/haskell-tools.nvim',
|
||||
enabled = not vim.g.vscode,
|
||||
enabled = is { 'standalone', 'linux' },
|
||||
version = '^3',
|
||||
ft = { 'haskell', 'lhaskell', 'cabal', 'cabalproject' },
|
||||
dependencies = {
|
Loading…
Reference in a new issue