feat(nvim): refactor config

This commit is contained in:
Maciej Jur 2024-01-21 23:32:15 +01:00
parent 46474a2653
commit 225b1b37f2
Signed by: kamov
GPG key ID: 191CBFF5F72ECAFD
11 changed files with 330 additions and 308 deletions

View file

@ -4,44 +4,23 @@ if vim.loader then
end end
-- Setup default options -- Setup default options
require "options" require 'config.options'
require "keymaps" require 'config.keymaps'
-- Are we inside Neovide? -- Are we inside Neovide?
if vim.g.neovide then if vim.g.neovide then
require "neovide" require 'config.neovide'
end end
-- Are we outside VSCode? -- Try load package manager
if not vim.g.vscode then local ok, err = pcall(function()
-- Bootstrap Lazy require 'config.manager'
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" end)
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
-- Load lazy if not ok and err then
local ok, err = pcall(function() vim.cmd 'colorscheme slate'
local plugins = require "plugins"
local lazy = require "lazy"
lazy.setup(plugins) vim.schedule(function()
vim.notify(err, vim.log.levels.ERROR)
end) end)
if not ok and err then
vim.cmd "colorscheme slate"
vim.schedule(function()
vim.notify(err, vim.log.levels.ERROR)
end)
end
end end

View file

@ -1,4 +1,5 @@
{ {
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
"LuaSnip": { "branch": "master", "commit": "8ae1dedd988eb56441b7858bd1e8554dfadaa46d" }, "LuaSnip": { "branch": "master", "commit": "8ae1dedd988eb56441b7858bd1e8554dfadaa46d" },
"bufferline.nvim": { "branch": "main", "commit": "6c456b888823d9e4832aa91c482bccd19445c009" }, "bufferline.nvim": { "branch": "main", "commit": "6c456b888823d9e4832aa91c482bccd19445c009" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
@ -7,27 +8,26 @@
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"diffview.nvim": { "branch": "main", "commit": "3dc498c9777fe79156f3d32dddd483b8b3dbd95f" }, "diffview.nvim": { "branch": "main", "commit": "3dc498c9777fe79156f3d32dddd483b8b3dbd95f" },
"gitsigns.nvim": { "branch": "main", "commit": "4aaacbf5e5e2218fd05eb75703fe9e0f85335803" }, "gitsigns.nvim": { "branch": "main", "commit": "c5ff7628e19a47ec14d3657294cc074ecae27b99" },
"haskell-tools.nvim": { "branch": "master", "commit": "6224672ffc44fc1bd95f79792277d95a92a67090" }, "haskell-tools.nvim": { "branch": "master", "commit": "2faa2c879c82652f1df3974c185901cf93c6367c" },
"kanagawa.nvim": { "branch": "master", "commit": "c19b9023842697ec92caf72cd3599f7dd7be4456" }, "kanagawa.nvim": { "branch": "master", "commit": "c19b9023842697ec92caf72cd3599f7dd7be4456" },
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, "lazy.nvim": { "branch": "main", "commit": "28126922c9b54e35a192ac415788f202c3944c9f" },
"lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" }, "lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "0989bdf4fdf7b5aa4c74131d7ffccc3f399ac788" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "3ba1b92b771f33256b4969d696b82c8ae7075364" },
"mason-nvim-dap.nvim": { "branch": "main", "commit": "3614a39aae98ccd34124b072939d6283853b3dd2" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "3614a39aae98ccd34124b072939d6283853b3dd2" },
"mason.nvim": { "branch": "main", "commit": "e110bc3be1a7309617cecd77bfe4bf86ba1b8134" }, "mason.nvim": { "branch": "main", "commit": "bce96d2fd483e71826728c6f9ac721fc9dd7d2cf" },
"neo-tree.nvim": { "branch": "v3.x", "commit": "77d9f484b88fd380386b46ed9206e5374d69d9d8" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "2f2d08894bbc679d4d181604c16bb7079f646384" },
"neodev.nvim": { "branch": "main", "commit": "dde00106b9094f101980b364fae02fd85d357306" }, "neodev.nvim": { "branch": "main", "commit": "aaeb44589cab39c2545a328661af355622d68479" },
"nui.nvim": { "branch": "main", "commit": "35da9ca1de0fc4dda96c2e214d93d363c145f418" }, "nui.nvim": { "branch": "main", "commit": "35da9ca1de0fc4dda96c2e214d93d363c145f418" },
"nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" },
"nvim-dap": { "branch": "master", "commit": "aad46274f09ba29933e4cef2257cdda5ec19cf7a" }, "nvim-dap": { "branch": "master", "commit": "9adbfdca13afbe646d09a8d7a86d5d031fb9c5a5" },
"nvim-dap-ui": { "branch": "master", "commit": "7e5e16427aaf814dc2d58e1b219def9ef2fa2435" }, "nvim-dap-ui": { "branch": "master", "commit": "a62e86b124a94ad1f34a3f936ea146d00aa096d1" },
"nvim-lspconfig": { "branch": "master", "commit": "e47ccfae775f0d572ef0f3a7d245f043b259dafc" }, "nvim-lspconfig": { "branch": "master", "commit": "8917d2c830e04bf944a699b8c41f097621283828" },
"nvim-notify": { "branch": "master", "commit": "1576123bff3bed67bc673a3076e591abfe5d8ca9" }, "nvim-notify": { "branch": "master", "commit": "80b67b265530632505193553d05127ae7fe09ddd" },
"nvim-treesitter": { "branch": "master", "commit": "8cd2b230174efbf7b5d9f49fe2f90bda6b5eb16e" }, "nvim-treesitter": { "branch": "master", "commit": "94bd4bcc5bbce8334303727627b628ece72e798d" },
"nvim-web-devicons": { "branch": "master", "commit": "584038666b0d8124d452a2e8ea9e38e6d6e56490" }, "nvim-web-devicons": { "branch": "master", "commit": "140edfcf25093e8b321d13e154cbce89ee868ca0" },
"plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, "plenary.nvim": { "branch": "master", "commit": "663246936325062427597964d81d30eaa42ab1e4" },
"presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, "rustaceanvim": { "branch": "master", "commit": "b0c03f052d24a2bfc4cc681075c2d81d3c3ac2f7" },
"rustaceanvim": { "branch": "master", "commit": "d03f72788b81cb311250d9fe0692f3435d609b5a" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
"telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, "telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" },
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }

View file

@ -0,0 +1,59 @@
local utils = require 'config.utils'
local map, augroup, autocmd = utils.keymap, utils.augroup, utils.autocmd
local n, t, nv = map 'n', map 't', map {'n', 'v'}
n '<leader>mn' ':Explore ~/.config/nvim/<cr>' 'Meta: open Neovim config'
n '<Leader>ex' ':Explore<CR>' 'Netrw: open'
n '<Leader>hl' ':nohl<CR>' 'Hide highlights'
n 'j' 'gj' 'Move: down by line'
n 'k' 'gk' 'Move: up by line'
n '<Leader>bn' ':bn<CR>' 'Buffer: next'
n '<Leader>bp' ':bp<CR>' 'Buffer: previous'
n '<Leader>bd' ':bd<CR>' 'Buffer: delete'
t '<Esc><Esc>' [[<C-\><C-n>]] 'Exit from terminal mode'
n '<C-h>' '<C-w>h' 'Window: move left'
n '<C-j>' '<C-w>j' 'Window: move down'
n '<C-k>' '<C-w>k' 'Window: move up'
n '<C-l>' '<C-w>l' 'Window: move right'
-- Diagnostics
n '<leader>e' (vim.diagnostic.open_float) 'Open error diagnostics'
n '[d' (vim.diagnostic.goto_prev) 'Previous diagnostic message'
n ']d' (vim.diagnostic.goto_next) 'Next diagnostic message'
n '<leader>dl' (vim.diagnostic.setloclist) 'Diagnostic: list messages'
-- LSP
autocmd 'LspAttach' {'LSP actions', group=augroup 'UserLspConfig'} (function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
local function workspaces_list()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end
local function format()
vim.lsp.buf.format({async = true})
end
local buffer = ev.buf
n 'K' (vim.lsp.buf.hover) {'Show hover help', buffer}
n 'gD' (vim.lsp.buf.declaration) {'Go to declaration', buffer}
n 'gd' (vim.lsp.buf.definition) {'Go to definition', buffer}
n 'gi' (vim.lsp.buf.implementation) {'Go to implementation', buffer}
n 'gr' (vim.lsp.buf.references) {'Show references', buffer}
n '<leader>D' (vim.lsp.buf.type_definition) {'Go to type definition', buffer}
n '<C-k>' (vim.lsp.buf.signature_help) {'Signature help', buffer}
n '<leader>wa' (vim.lsp.buf.add_workspace_folder) {'Add workspace folder', buffer}
n '<leader>wr' (vim.lsp.buf.remove_workspace_folder) {'Remove workspace folder', buffer}
n '<leader>wl' (workspaces_list) {'List workspace folders', buffer}
n '<leader>lr' (vim.lsp.buf.rename) {'Rename identifier', buffer}
nv '<leader>la' (vim.lsp.buf.code_action) {'Show code actions', buffer}
n '<leader>lf' (format) {'Format file', buffer}
end)

View file

@ -0,0 +1,23 @@
local data = vim.fn.stdpath 'data'
local path = data .. '/lazy/lazy.nvim'
-- Bootstrap
if not vim.loop.fs_stat(path) then
vim.fn.system {
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable',
path,
}
end
vim.opt.rtp:prepend(path)
-- Load
local plugins = require 'plugins'
local lazy = require 'lazy'
-- Init
lazy.setup(plugins)

View file

@ -4,30 +4,29 @@ local options = {
cursor_animation_length = 0.05, cursor_animation_length = 0.05,
} }
for key, value in pairs(options) do for key, val in pairs(options) do
vim.g['neovide_' .. key] = value vim.g['neovide_' .. key] = val
end end
-- Japanese IME compat -- Japanese IME compat
local function set_ime(args) local function set_ime(args)
if args.event:match("Enter$") then if args.event:match 'Enter$' then
vim.g.neovide_input_ime = true vim.g.neovide_input_ime = true
else else
vim.g.neovide_input_ime = false vim.g.neovide_input_ime = false
end end
end end
local ime_input = vim.api.nvim_create_augroup("ime_input", { clear = true }) local ime_input = vim.api.nvim_create_augroup('ime_input', { clear = true })
vim.api.nvim_create_autocmd({ "InsertEnter", "InsertLeave" }, { vim.api.nvim_create_autocmd({ 'InsertEnter', 'InsertLeave' }, {
group = ime_input, group = ime_input,
pattern = "*", pattern = '*',
callback = set_ime callback = set_ime
}) })
vim.api.nvim_create_autocmd({ "CmdlineEnter", "CmdlineLeave" }, { vim.api.nvim_create_autocmd({ 'CmdlineEnter', 'CmdlineLeave' }, {
group = ime_input, group = ime_input,
pattern = "[/\\?]", pattern = '[/\\?]',
callback = set_ime callback = set_ime
}) })

View file

@ -1,5 +1,5 @@
local U = require("utility") local utils = require 'config.utils'
local autocmd = U.autocmd local autocmd = utils.autocmd
local g, opt = vim.g, vim.opt local g, opt = vim.g, vim.opt
@ -10,9 +10,9 @@ g.loaded_perl_provider = 0
g.loaded_node_provider = 0 g.loaded_node_provider = 0
-- General -- General
opt.clipboard = "unnamedplus" -- Use system clipboard opt.clipboard = 'unnamedplus' -- Use system clipboard
opt.swapfile = false -- Don't use swapfiles opt.swapfile = false -- Don't use swapfiles
opt.completeopt = "menuone,noinsert,noselect" -- Completion behavior opt.completeopt = 'menuone,noinsert,noselect' -- Completion behavior
opt.termguicolors = true opt.termguicolors = true
-- Indentation -- Indentation
@ -24,19 +24,19 @@ opt.expandtab = true -- Use spaces instead of tabs
-- Visual -- Visual
opt.number = true -- Show current line number opt.number = true -- Show current line number
opt.relativenumber = true -- Show relative line numbers opt.relativenumber = true -- Show relative line numbers
opt.colorcolumn = "80" -- Show soft char limit opt.colorcolumn = '80' -- Show soft char limit
opt.list = true -- Show punctuation opt.list = true -- Show punctuation
opt.listchars = { -- Punctuation marks opt.listchars = { -- Punctuation marks
trail = "·", trail = '·',
nbsp = "", nbsp = '',
tab = "", tab = '',
leadmultispace = "", leadmultispace = '',
} }
-- Trailing whitespace -- Trailing whitespace
autocmd "BufWritePre" {} (function() autocmd 'BufWritePre' {} (function()
if vim.bo.filetype == "markdown" then return end if vim.bo.filetype == 'markdown' then return end
vim.cmd([[%s/\s\+$//e]]) vim.cmd [[%s/\s\+$//e]]
end) end)
-- Additional filetypes -- Additional filetypes

View file

@ -1,5 +1,6 @@
local M = {} local M = {}
local def_opts = {noremap = true, silent = true}
local defaults = { noremap = true, silent = true }
---@class KeymapOpts ---@class KeymapOpts
@ -19,13 +20,13 @@ function M.keymap(modes)
return function(opts) return function(opts)
local type = type(opts) local type = type(opts)
local options local options
if type == "string" then if type == 'string' then
options = vim.tbl_extend("force", def_opts, {desc=opts}) options = vim.tbl_extend('force', defaults, {desc=opts})
elseif type == "table" then elseif type == 'table' then
opts.desc = opts[1] or opts.desc opts.desc = opts[1] or opts.desc
opts.buffer = opts[2] or opts.buffer opts.buffer = opts[2] or opts.buffer
opts[1], opts[2] = nil, nil opts[1], opts[2] = nil, nil
options = vim.tbl_extend("force", def_opts, opts) options = vim.tbl_extend('force', defaults, opts)
end end
vim.keymap.set(modes, lhs, rhs, options) vim.keymap.set(modes, lhs, rhs, options)
end end
@ -44,9 +45,9 @@ end
function M.augroup(opts) function M.augroup(opts)
local type = type(opts) local type = type(opts)
local name, options local name, options
if type == "string" then if type == 'string' then
name, options = opts, {} name, options = opts, {}
elseif type == "table" then elseif type == 'table' then
name, options = opts[1], opts name, options = opts[1], opts
options[1] = nil options[1] = nil
end end
@ -81,7 +82,7 @@ function M.as_extendable(config)
---@param base LazyPluginSpec ---@param base LazyPluginSpec
---@return LazyPluginSpec ---@return LazyPluginSpec
return function(base) return function(base)
return vim.tbl_extend("keep", base, config) return vim.tbl_extend('keep', base, config)
end end
end end

View file

@ -1,59 +0,0 @@
local U = require("utility")
local map, augroup, autocmd = U.keymap, U.augroup, U.autocmd
local n, t, nv = map 'n', map 't', map {'n', 'v'}
n "<leader>mn" ":Explore ~/.config/nvim/<cr>" "Meta: open Neovim config"
n "<Leader>ex" ":Explore<CR>" "Netrw: open"
n "<Leader>hl" ":nohl<CR>" "Hide highlights"
n "j" "gj" "Move: down by line"
n "k" "gk" "Move: up by line"
n "<Leader>bn" ":bn<CR>" "Buffer: next"
n "<Leader>bp" ":bp<CR>" "Buffer: previous"
n "<Leader>bd" ":bd<CR>" "Buffer: delete"
t "<Esc><Esc>" [[<C-\><C-n>]] "Exit from terminal mode"
n "<C-h>" "<C-w>h" "Window: move left"
n "<C-j>" "<C-w>j" "Window: move down"
n "<C-k>" "<C-w>k" "Window: move up"
n "<C-l>" "<C-w>l" "Window: move right"
-- Diagnostics
n "<leader>e" (vim.diagnostic.open_float) "Open error diagnostics"
n "[d" (vim.diagnostic.goto_prev) "Previous diagnostic message"
n "]d" (vim.diagnostic.goto_next) "Next diagnostic message"
n "<leader>dl" (vim.diagnostic.setloclist) "Diagnostic: list messages"
-- LSP
autocmd "LspAttach" {"LSP actions", group=augroup "UserLspConfig"} (function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
local function workspaces_list()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end
local function format()
vim.lsp.buf.format({async = true})
end
local buffer = ev.buf
n "K" (vim.lsp.buf.hover) {"Show hover help", buffer}
n "gD" (vim.lsp.buf.declaration) {"Go to declaration", buffer}
n "gd" (vim.lsp.buf.definition) {"Go to definition", buffer}
n "gi" (vim.lsp.buf.implementation) {"Go to implementation", buffer}
n "gr" (vim.lsp.buf.references) {"Show references", buffer}
n "<leader>D" (vim.lsp.buf.type_definition) {"Go to type definition", buffer}
n "<C-k>" (vim.lsp.buf.signature_help) {"Signature help", buffer}
n "<leader>wa" (vim.lsp.buf.add_workspace_folder) {"Add workspace folder", buffer}
n "<leader>wr" (vim.lsp.buf.remove_workspace_folder) {"Remove workspace folder", buffer}
n "<leader>wl" (workspaces_list) {"List workspace folders", buffer}
n "<leader>lr" (vim.lsp.buf.rename) {"Rename identifier", buffer}
nv "<leader>la" (vim.lsp.buf.code_action) {"Show code actions", buffer}
n "<leader>lf" (format) {"Format file", buffer}
end)

View file

@ -1,5 +1,5 @@
local U = require "utility" local util = require 'config.utils'
local n = U.keymap "n" local n = util.keymap 'n'
---@type LazySpec ---@type LazySpec
@ -7,138 +7,67 @@ return {
-- Theme -- Theme
{ {
"rebelot/kanagawa.nvim", 'rebelot/kanagawa.nvim',
enabled = not vim.g.vscode,
lazy = false, lazy = false,
priority = math.huge, priority = math.huge,
config = function() config = function()
vim.cmd "colorscheme kanagawa" vim.cmd 'colorscheme kanagawa'
end, end,
}, },
-- Status line -- Status line
{ {
"nvim-lualine/lualine.nvim", 'nvim-lualine/lualine.nvim',
enabled = not vim.g.vscode,
dependencies = { dependencies = {
"nvim-tree/nvim-web-devicons", 'nvim-tree/nvim-web-devicons',
}, },
config = function() config = function()
local lualine = require "lualine" local lualine = require 'lualine'
lualine.setup {} lualine.setup {}
end end
}, },
-- Telescope -- Telescope
{ {
"nvim-telescope/telescope.nvim", 'nvim-telescope/telescope.nvim',
branch = "0.1.x", enabled = not vim.g.vscode,
branch = '0.1.x',
dependencies = { dependencies = {
"nvim-lua/plenary.nvim", 'nvim-lua/plenary.nvim',
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" } { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }
}, },
config = function() config = function()
local telescope = require "telescope" local telescope = require 'telescope'
local builtin = require "telescope.builtin" local builtin = require 'telescope.builtin'
local ext = telescope.extensions local ext = telescope.extensions
telescope.load_extension "fzf" telescope.load_extension 'fzf'
telescope.load_extension "notify" telescope.load_extension 'notify'
telescope.setup { telescope.setup {
extensions = { extensions = {
fzf = { fzf = {
fuzzy = true, fuzzy = true,
override_generic_sorter = true, override_generic_sorter = true,
override_file_sorter = true, override_file_sorter = true,
case_mode = "smart_case", case_mode = 'smart_case',
} }
} }
} }
n "<leader>ff" (builtin.find_files) "Telescope: find files" n '<leader>ff' (builtin.find_files) 'Telescope: find files'
n "<leader>fb" (builtin.buffers) "Telescope: find buffers" n '<leader>fb' (builtin.buffers) 'Telescope: find buffers'
n "<leader>fg" (builtin.live_grep) "Telescope: grep content" n '<leader>fg' (builtin.live_grep) 'Telescope: grep content'
n "<leader>fh" (builtin.help_tags) "Telescope: search docs" n '<leader>fh' (builtin.help_tags) 'Telescope: search docs'
n "<leader>fn" (ext.notify.notify) "Telescope: find notifications" n '<leader>fn' (ext.notify.notify) 'Telescope: find notifications'
end, end,
}, },
-- Shortcut hints
{
"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
opts = {}
},
-- Notifications
{
"rcarriga/nvim-notify",
config = function()
vim.notify = require "notify"
end
},
-- File tree
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim",
},
},
-- Bufferline
{
"akinsho/bufferline.nvim",
version = "*",
dependencies = {
"nvim-tree/nvim-web-devicons"
},
config = function()
local config = require "bufferline"
config.setup()
end
},
-- Git diffviewer
{
"sindrets/diffview.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
},
},
-- Git signs
{
"lewis6991/gitsigns.nvim",
config = function()
local gitsigns = require "gitsigns"
gitsigns.setup()
end,
},
{
"andweeb/presence.nvim",
config = function()
local presence = require "presence"
presence.setup {
main_image = "file",
show_time = false,
buttons = false,
}
end
},
-- Treesitter -- Treesitter
{ {
"nvim-treesitter/nvim-treesitter", 'nvim-treesitter/nvim-treesitter',
build = ":TSUpdate", build = ':TSUpdate',
config = function() config = function()
local configs = require 'nvim-treesitter.configs' local configs = require 'nvim-treesitter.configs'
@ -149,32 +78,41 @@ return {
ignore_install = {}, ignore_install = {},
ensure_installed = { ensure_installed = {
-- neovim -- neovim
"vimdoc", "lua", "query", 'vimdoc', 'lua', 'query',
-- data -- data
"json", "xml", "yaml", "toml", "dhall", 'json', 'xml', 'yaml', 'toml', 'dhall',
-- markdown -- markdown
"markdown", "markdown_inline", 'markdown', 'markdown_inline',
-- latex -- latex
"latex", "bibtex", 'latex', 'bibtex',
-- git -- git
"gitcommit", "gitignore", "diff", 'gitcommit', 'gitignore', 'diff',
-- misc -- misc
"comment", "dockerfile", "regex", 'comment', 'dockerfile', 'regex',
-- shell -- shell
"bash", 'bash',
-- julia -- julia
"julia", 'julia',
-- python -- python
"python", 'python',
-- rust -- rust
"rust", 'rust',
-- webdev -- webdev
"html", "css", "scss", "javascript", "jsdoc", "typescript", "tsx", "astro", "svelte", 'html', 'css', 'scss', 'javascript', 'jsdoc', 'typescript', 'tsx', 'astro', 'svelte',
-- haskell -- haskell
"haskell", "purescript", "nix", 'haskell', 'purescript', 'nix',
}, },
highlight = { enable = true }, highlight = { enable = true },
indent = { enable = true }, indent = { enable = true },
incremental_selection = {
enable = true,
keymaps = {
init_selection = '<CR>',
scope_incremental = '<CR>',
node_incremental = '<TAB>',
node_decremental = '<S-TAB>',
},
},
} }
end, end,
init = function() init = function()
@ -185,14 +123,88 @@ return {
end, end,
}, },
-- Git signs
{
'lewis6991/gitsigns.nvim',
enabled = not vim.g.vscode,
config = function()
local gitsigns = require 'gitsigns'
gitsigns.setup()
end,
},
-- Comments
{
'numToStr/Comment.nvim',
config = true,
},
-- Shortcut hints
{
'folke/which-key.nvim',
enabled = not vim.g.vscode,
event = 'VeryLazy',
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
opts = {}
},
-- Notifications
{
'rcarriga/nvim-notify',
enabled = not vim.g.vscode,
config = function()
vim.notify = require 'notify'
end
},
-- File tree
{
'nvim-neo-tree/neo-tree.nvim',
enabled = not vim.g.vscode,
branch = 'v3.x',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-tree/nvim-web-devicons',
'MunifTanjim/nui.nvim',
},
},
-- 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,
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-tree/nvim-web-devicons',
},
},
-- LS configs -- LS configs
{ {
"neovim/nvim-lspconfig", 'neovim/nvim-lspconfig',
enabled = not vim.g.vscode,
opts = { opts = {
inlay_hints = { enabled = true }, inlay_hints = { enabled = true },
}, },
config = function() config = function()
local lsp = require "lspconfig" local lsp = require 'lspconfig'
lsp.nushell.setup {} lsp.nushell.setup {}
end, end,
@ -200,60 +212,64 @@ return {
-- Snippet engine -- Snippet engine
{ {
"L3MON4D3/LuaSnip", 'L3MON4D3/LuaSnip',
version = "2.*", version = '2.*',
}, },
-- Completion -- Completion
require "plugins.nvim-cmp" { require 'plugins.nvim-cmp' {
"hrsh7th/nvim-cmp", 'hrsh7th/nvim-cmp',
dependencies = { dependencies = {
"hrsh7th/cmp-cmdline", 'hrsh7th/cmp-cmdline',
"hrsh7th/cmp-buffer", 'hrsh7th/cmp-buffer',
"hrsh7th/cmp-path", 'hrsh7th/cmp-path',
"hrsh7th/cmp-nvim-lsp", 'hrsh7th/cmp-nvim-lsp',
"saadparwaiz1/cmp_luasnip", 'saadparwaiz1/cmp_luasnip',
}, },
}, },
-- Debugger adapter support -- Debugger adapter support
{ {
"mfussenegger/nvim-dap", 'mfussenegger/nvim-dap',
enabled = not vim.g.vscode,
config = function() config = function()
local dap = require "dap" local dap = require 'dap'
n "<leader>b" (dap.toggle_breakpoint) "DAP: Toggle breakpoint" n '<leader>b' (dap.toggle_breakpoint) 'DAP: Toggle breakpoint'
end, end,
}, },
-- Debugger UI -- Debugger UI
require "plugins.nvim-dap-ui" { require 'plugins.nvim-dap-ui' {
"rcarriga/nvim-dap-ui", 'rcarriga/nvim-dap-ui',
enabled = not vim.g.vscode,
dependencies = { dependencies = {
"mfussenegger/nvim-dap", 'mfussenegger/nvim-dap',
}, },
}, },
-- Mason -- Mason
{ {
"williamboman/mason.nvim", 'williamboman/mason.nvim',
enabled = not vim.g.vscode,
config = function() config = function()
local mason = require "mason" local mason = require 'mason'
mason.setup() mason.setup()
end, end,
}, },
-- Automatic LSP server setup for Mason -- Automatic LSP server setup for Mason
{ {
"williamboman/mason-lspconfig.nvim", 'williamboman/mason-lspconfig.nvim',
enabled = not vim.g.vscode,
dependencies = { dependencies = {
"williamboman/mason.nvim", 'williamboman/mason.nvim',
"neovim/nvim-lspconfig", 'neovim/nvim-lspconfig',
}, },
config = function() config = function()
local config = require "mason-lspconfig" local config = require 'mason-lspconfig'
local lsp = require "lspconfig" local lsp = require 'lspconfig'
local cmp = require "cmp_nvim_lsp" local cmp = require 'cmp_nvim_lsp'
local noop = function() end local noop = function() end
@ -262,19 +278,19 @@ return {
-- NOTE -- NOTE
-- Haskell: Managed by GHCup -- Haskell: Managed by GHCup
ensure_installed = { ensure_installed = {
"lua_ls", -- Lua 'lua_ls', -- Lua
"rust_analyzer", -- Rust 'rust_analyzer', -- Rust
"bashls", -- Bash 'bashls', -- Bash
"html", -- HTML 'html', -- HTML
"cssls", -- CSS / SCSS 'cssls', -- CSS / SCSS
"tsserver", -- TypeScript 'tsserver', -- TypeScript
"astro", -- Astro 'astro', -- Astro
"svelte", -- Svelte 'svelte', -- Svelte
"pyright", -- Python 'pyright', -- Python
"rnix", -- Nix 'rnix', -- Nix
"purescriptls", -- Purescript 'purescriptls', -- Purescript
"ltex", -- Literate - LaTeX, Markdown, etc. 'ltex', -- Literate - LaTeX, Markdown, etc.
"julials", -- Julia 'julials', -- Julia
}, },
} }
@ -292,18 +308,19 @@ return {
-- Automatic debugger install -- Automatic debugger install
{ {
"jay-babu/mason-nvim-dap.nvim", 'jay-babu/mason-nvim-dap.nvim',
enabled = not vim.g.vscode,
dependencies = { dependencies = {
"mfussenegger/nvim-dap", 'mfussenegger/nvim-dap',
"williamboman/mason.nvim", 'williamboman/mason.nvim',
}, },
config = function() config = function()
local config = require "mason-nvim-dap" local config = require 'mason-nvim-dap'
config.setup { config.setup {
automatic_installation = true, automatic_installation = true,
ensure_installed = { ensure_installed = {
"codelldb", 'codelldb',
}, },
} }
end, end,
@ -311,19 +328,20 @@ return {
-- Tools for Neovim -- Tools for Neovim
{ {
"folke/neodev.nvim", 'folke/neodev.nvim',
ft = "lua", enabled = not vim.g.vscode,
ft = 'lua',
dependencies = { dependencies = {
"neovim/nvim-lspconfig", 'neovim/nvim-lspconfig',
}, },
config = function() config = function()
local neodev = require "neodev" local neodev = require 'neodev'
local lsp = require "lspconfig" local lsp = require 'lspconfig'
neodev.setup() neodev.setup()
lsp.lua_ls.setup { lsp.lua_ls.setup {
settings = { settings = {
Lua = { completion = { callSnippet = "Replace" } } Lua = { completion = { callSnippet = 'Replace' } }
} }
} }
end end
@ -331,22 +349,24 @@ return {
-- Tools for Rust -- Tools for Rust
{ {
"mrcjkb/rustaceanvim", 'mrcjkb/rustaceanvim',
version = "^3", enabled = not vim.g.vscode,
ft = { "rust" }, version = '^3',
ft = { 'rust' },
init = function() init = function()
require 'plugins.rust-tools' require 'plugins.rust-tools'
end end
}, },
-- Tools for Haskell -- Tools for Haskell
require "plugins.haskell-tools" { require 'plugins.haskell-tools' {
"mrcjkb/haskell-tools.nvim", 'mrcjkb/haskell-tools.nvim',
version = "^3", enabled = not vim.g.vscode,
ft = { "haskell", "lhaskell", "cabal", "cabalproject" }, version = '^3',
ft = { 'haskell', 'lhaskell', 'cabal', 'cabalproject' },
dependencies = { dependencies = {
"nvim-lua/plenary.nvim", 'nvim-lua/plenary.nvim',
"nvim-telescope/telescope.nvim", 'nvim-telescope/telescope.nvim',
}, },
}, },

View file

@ -1,5 +1,5 @@
local U = require 'utility' local utils = require 'config.utils'
local n = U.keymap 'n' local n = utils.keymap 'n'
---@param buffer number ---@param buffer number
@ -24,7 +24,7 @@ local function on_attach(_, buffer, ht)
end end
return U.as_extendable { return utils.as_extendable {
init = function() init = function()
vim.g.haskell_tools = { vim.g.haskell_tools = {
---@type HaskellLspClientOpts` ---@type HaskellLspClientOpts`

View file

@ -1,5 +1,5 @@
local util = require 'utility' local util = require 'config.utils'
local n = util.keymap 'n' local n = util.keymap 'n'
vim.g.rustaceanvim = function() vim.g.rustaceanvim = function()