nvim: use tabs

This commit is contained in:
Maciej Jur 2024-06-13 21:48:16 +02:00
parent 836cd21dbb
commit 57bea4647b
Signed by: kamov
GPG key ID: 191CBFF5F72ECAFD
16 changed files with 603 additions and 623 deletions

View file

@ -1,5 +1,5 @@
local ok, err = pcall(require, 'main') local ok, err = pcall(require, 'main')
if not ok then if not ok then
print('Error: ' .. err) print('Error: ' .. err)
end end

View file

@ -3,11 +3,11 @@
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"diffview.nvim": { "branch": "main", "commit": "3afa6a053f680e9f1329c4a151db988a482306cd" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
"dropbar.nvim": { "branch": "master", "commit": "2b546383bdf4daa254ac70c760ee1e5524bc60b1" }, "dropbar.nvim": { "branch": "master", "commit": "fd917b70535371d45285bc94f9eb6387677c6dce" },
"gitsigns.nvim": { "branch": "main", "commit": "4a143f13e122ab91abdc88f89eefbe70a4858a56" }, "gitsigns.nvim": { "branch": "main", "commit": "47c8e3e571376b24de62408fd0c9d12f0a9fc0a3" },
"haskell-tools.nvim": { "branch": "master", "commit": "65d6993eba1a56bbd5211ef13a100d26ce3e644a" }, "haskell-tools.nvim": { "branch": "master", "commit": "65d6993eba1a56bbd5211ef13a100d26ce3e644a" },
"kanagawa.nvim": { "branch": "master", "commit": "08ed29989834f5f2606cb1ef9d5b24c5ea7b8fa5" }, "kanagawa.nvim": { "branch": "master", "commit": "fe5b2c9e2549862c3dc3f3c8e9cf7ddece0f40c2" },
"lazy.nvim": { "branch": "main", "commit": "eb4957442e3182f051b0ae11da32e06d22c190e3" }, "lazy.nvim": { "branch": "main", "commit": "eb4957442e3182f051b0ae11da32e06d22c190e3" },
"lazydev.nvim": { "branch": "main", "commit": "7cbb524c85f87017df9c1ea2377a1d840ad8ed51" }, "lazydev.nvim": { "branch": "main", "commit": "7cbb524c85f87017df9c1ea2377a1d840ad8ed51" },
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
@ -18,14 +18,14 @@
"nvim-lspconfig": { "branch": "master", "commit": "4d38bece98300e3e5cd24a9aa0d0ebfea4951c16" }, "nvim-lspconfig": { "branch": "master", "commit": "4d38bece98300e3e5cd24a9aa0d0ebfea4951c16" },
"nvim-nio": { "branch": "master", "commit": "7969e0a8ffabdf210edd7978ec954a47a737bbcc" }, "nvim-nio": { "branch": "master", "commit": "7969e0a8ffabdf210edd7978ec954a47a737bbcc" },
"nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" },
"nvim-treesitter": { "branch": "master", "commit": "9a7ad2ff7a7ea81016aca2fc89c9b2c1a5365421" }, "nvim-treesitter": { "branch": "master", "commit": "9636d5a3f4f531256fba147a30b882c44f28fae1" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" },
"nvim-web-devicons": { "branch": "master", "commit": "c0cfc1738361b5da1cd0a962dd6f774cc444f856" }, "nvim-web-devicons": { "branch": "master", "commit": "c0cfc1738361b5da1cd0a962dd6f774cc444f856" },
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
"precognition.nvim": { "branch": "main", "commit": "5255b72c52b1159e9757f50389bde65e05e3bfb1" }, "precognition.nvim": { "branch": "main", "commit": "9e6087fcd27dd5d2fc71b9d9471a101666c39f73" },
"rustaceanvim": { "branch": "master", "commit": "bc8c4b8f7606d5b7c067cd8369e25c1a7ff77bd0" }, "rustaceanvim": { "branch": "master", "commit": "bc8c4b8f7606d5b7c067cd8369e25c1a7ff77bd0" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" },
"telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
"trouble.nvim": { "branch": "main", "commit": "5e45bb78f8da3444d35616934c180fce3742c439" }, "trouble.nvim": { "branch": "main", "commit": "e0b35a273df58b03612255783cf475a782ede7e0" },
"which-key.nvim": { "branch": "main", "commit": "0099511294f16b81c696004fa6a403b0ae61f7a0" } "which-key.nvim": { "branch": "main", "commit": "0099511294f16b81c696004fa6a403b0ae61f7a0" }
} }

View file

@ -3,43 +3,43 @@ local group = vim.api.nvim_create_augroup('UserGroup', {})
-- Remove trailing whitespace on write -- Remove trailing whitespace on write
vim.api.nvim_create_autocmd('BufWritePre', { vim.api.nvim_create_autocmd('BufWritePre', {
group = group, group = group,
pattern = '*', pattern = '*',
callback = function() callback = 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
}) })
-- Highlight yank -- Highlight yank
vim.api.nvim_create_autocmd('TextYankPost', { vim.api.nvim_create_autocmd('TextYankPost', {
group = group, group = group,
pattern = '*', pattern = '*',
callback = function() callback = function()
vim.highlight.on_yank { timeout = 250 } vim.highlight.on_yank { timeout = 250 }
end end
}) })
-- Restore cursor position -- Restore cursor position
vim.api.nvim_create_autocmd('BufReadPost', { vim.api.nvim_create_autocmd('BufReadPost', {
group = group, group = group,
callback = function(args) callback = function(args)
if if
vim.fn.line [['"]] >= 1 and vim.fn.line [['"]] >= 1 and
vim.fn.line [['"]] < vim.fn.line '$' and vim.fn.line [['"]] < vim.fn.line '$' and
vim.b[args.buf].filetype ~= 'commit' vim.b[args.buf].filetype ~= 'commit'
then then
vim.cmd [[normal! g`"]] vim.cmd [[normal! g`"]]
end end
end end
}) })
-- Set indentation for Rust -- Set indentation for Rust
vim.api.nvim_create_autocmd('FileType', { vim.api.nvim_create_autocmd('FileType', {
pattern = 'rust', pattern = 'rust',
callback = function() callback = function()
vim.opt_local.tabstop = 4 vim.opt_local.tabstop = 4
vim.opt_local.shiftwidth = 4 vim.opt_local.shiftwidth = 4
vim.opt_local.listchars:append { leadmultispace = '' } vim.opt_local.listchars:append { leadmultispace = '' }
end end
}) })

View file

@ -5,37 +5,37 @@
---@type table<ComposerTag, boolean> ---@type table<ComposerTag, boolean>
local env = { local env = {
standalone = not vim.g.vscode, standalone = not vim.g.vscode,
linux = jit.os == 'Linux', linux = jit.os == 'Linux',
} }
---@param tags ComposerTag | ComposerTag[] ---@param tags ComposerTag | ComposerTag[]
---@return boolean ---@return boolean
local function is(tags) local function is(tags)
if type(tags) == 'string' then if type(tags) == 'string' then
return env[tags] or false return env[tags] or false
end end
for _, tag in ipairs(tags) do for _, tag in ipairs(tags) do
if not env[tag] then if not env[tag] then
return false return false
end end
end end
return true return true
end end
---@param tags ComposerTag | ComposerTag[] ---@param tags ComposerTag | ComposerTag[]
local function when(tags) local function when(tags)
local match = is(tags) local match = is(tags)
---@generic T ---@generic T
---@param value `T` ---@param value `T`
---@return T | nil ---@return T | nil
return function(value) return function(value)
return match and value or nil return match and value or nil
end end
end end
return function() return function()
return is, when return is, when
end end

View file

@ -1,4 +1,4 @@
return { return {
keymap = require 'config.helpers.keymap', keymap = require 'config.helpers.keymap',
visual = require 'config.helpers.visual', visual = require 'config.helpers.visual',
} }

View file

@ -1,5 +1,6 @@
local defaults = { noremap = true, silent = true } local defaults = { noremap = true, silent = true }
---@class KeymapOpts ---@class KeymapOpts
---@field [1]? string Shorthand description ---@field [1]? string Shorthand description
---@field desc? string Description ---@field desc? string Description
@ -9,27 +10,27 @@ local defaults = { noremap = true, silent = true }
---Wrapper around `vim.keymap.set` ---Wrapper around `vim.keymap.set`
---@param modes string|string[] ---@param modes string|string[]
return function(modes) return function(modes)
---@param lhs string ---@param lhs string
return function(lhs) return function(lhs)
---@param rhs string|function ---@param rhs string|function
return function(rhs) return function(rhs)
---@param opts string|KeymapOpts ---@param opts string|KeymapOpts
return function(opts) return function(opts)
local kind = type(opts) ---@cast kind 'string'|'table' local kind = type(opts) ---@cast kind 'string'|'table'
---@type table ---@type table
local options local options
if kind == 'string' then if kind == 'string' then
options = vim.tbl_extend('force', defaults, {desc=opts}) options = vim.tbl_extend('force', defaults, { desc = opts })
else else
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', defaults, 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
end end
end end
end end

View file

@ -7,13 +7,13 @@
---Get current visual selection area ---Get current visual selection area
---@return VisualArea ---@return VisualArea
return function() return function()
local select = vim.fn.getpos 'v' local select = vim.fn.getpos 'v'
local cursor = vim.fn.getpos '.' local cursor = vim.fn.getpos '.'
local sr, er = select[2], cursor[2] local sr, er = select[2], cursor[2]
local sc, ec = select[3], cursor[3] local sc, ec = select[3], cursor[3]
if sc > ec then sc, ec = ec, sc end if sc > ec then sc, ec = ec, sc end
if sr > er then sr, er = er, sr end if sr > er then sr, er = er, sr end
return { sr = sr, sc = sc, er = er, ec = ec } return { sr = sr, sc = sc, er = er, ec = ec }
end end

View file

@ -7,25 +7,25 @@ local nv = map {'n', 'v'}
n 'j' 'gj' 'Move: down by line' n 'j' 'gj' 'Move: down by line'
n 'k' 'gk' 'Move: up by line' n 'k' 'gk' 'Move: up by line'
n '<Leader>bn' ':bn<CR>' 'Buffer: next' n '<Leader>bn' ':bn<CR>' 'Buffer: next'
n '<Leader>bp' ':bp<CR>' 'Buffer: previous' n '<Leader>bp' ':bp<CR>' 'Buffer: previous'
n '<Leader>bd' ':bd<CR>' 'Buffer: delete' n '<Leader>bd' ':bd<CR>' 'Buffer: delete'
t '<Esc><Esc>' [[<C-\><C-n>]] 'Exit from terminal mode' t '<Esc><Esc>' [[<C-\><C-n>]] 'Exit from terminal mode'
n '<C-h>' '<C-w>h' 'Window: move left' n '<C-h>' '<C-w>h' 'Window: move left'
n '<C-j>' '<C-w>j' 'Window: move down' n '<C-j>' '<C-w>j' 'Window: move down'
n '<C-k>' '<C-w>k' 'Window: move up' n '<C-k>' '<C-w>k' 'Window: move up'
n '<C-l>' '<C-w>l' 'Window: move right' n '<C-l>' '<C-w>l' 'Window: move right'
-- Indentation -- Indentation
v '>' '>gv' 'Indent right' v '>' '>gv' 'Indent right'
v '<' '<gv' 'Indent left' v '<' '<gv' 'Indent left'
v '|' (indent.normalize) 'Indent normalize' v '|' (indent.normalize) 'Indent normalize'
-- Diagnostics -- Diagnostics
@ -36,20 +36,20 @@ n '<leader>dl' (vim.diagnostic.setloclist) 'Diagnostic: list messages'
-- X -- X
local function insert_date() local function insert_date()
local row, col = unpack(vim.api.nvim_win_get_cursor(0)) local row, col = unpack(vim.api.nvim_win_get_cursor(0))
local text = os.date '!%Y-%m-%dT%H:%M:%SZ' ---@cast text string local text = os.date '!%Y-%m-%dT%H:%M:%SZ' ---@cast text string
col = math.min(#vim.api.nvim_get_current_line(), col + 1) col = math.min(#vim.api.nvim_get_current_line(), col + 1)
vim.api.nvim_buf_set_text(0, row - 1, col, row - 1, col, { text }) vim.api.nvim_buf_set_text(0, row - 1, col, row - 1, col, { text })
end end
n '<Leader>xd' (insert_date) 'Execute: full date' n '<Leader>xd' (insert_date) 'Execute: full date'
v '<Leader>xs' ':sort<CR>' 'Execute: sort' v '<Leader>xs' ':sort<CR>' 'Execute: sort'
-- Meta -- Meta
local function open_config() local function open_config()
vim.fn.chdir '~/.config/nvim' vim.fn.chdir '~/.config/nvim'
vim.cmd 'Explore' vim.cmd 'Explore'
end end
n '<leader>mn' (open_config) 'Meta: neovim config' n '<leader>mn' (open_config) 'Meta: neovim config'
@ -59,49 +59,49 @@ n '<leader>mm' ':Mason<CR>' 'Meta: mason'
-- LSP -- LSP
do do
local group = vim.api.nvim_create_augroup('UserLspConfig', {}) local group = vim.api.nvim_create_augroup('UserLspConfig', {})
local function setup_lsp_keymaps(ev) local function setup_lsp_keymaps(ev)
-- Enable completion triggered by <c-x><c-o> -- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
local function format() local function format()
vim.lsp.buf.format({ async = true }) vim.lsp.buf.format({ async = true })
end end
local function format_selection() local function format_selection()
vim.lsp.buf.format({ vim.lsp.buf.format({
async = true, async = true,
range = { range = {
["start"] = vim.api.nvim_buf_get_mark(0, "<"), ["start"] = vim.api.nvim_buf_get_mark(0, "<"),
["end"] = vim.api.nvim_buf_get_mark(0, ">"), ["end"] = vim.api.nvim_buf_get_mark(0, ">"),
} }
}) })
end end
local function workspaces_list() local function workspaces_list()
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end end
local buffer = ev.buf local buffer = ev.buf
n 'K' (vim.lsp.buf.hover) {'LSP: show hover help', buffer} n 'K' (vim.lsp.buf.hover) {'LSP: show hover help', buffer}
n '<C-k>' (vim.lsp.buf.signature_help) {'LSP: signature help', buffer} n '<C-k>' (vim.lsp.buf.signature_help) {'LSP: signature help', buffer}
n '<Leader>ld' (vim.lsp.buf.definition) {'LSP: definition', buffer} n '<Leader>ld' (vim.lsp.buf.definition) {'LSP: definition', buffer}
n '<Leader>lD' (vim.lsp.buf.declaration) {'LSP: declaration', buffer} n '<Leader>lD' (vim.lsp.buf.declaration) {'LSP: declaration', buffer}
n '<Leader>li' (vim.lsp.buf.implementation) {'LSP: implementation', buffer} n '<Leader>li' (vim.lsp.buf.implementation) {'LSP: implementation', buffer}
n '<Leader>lR' (vim.lsp.buf.references) {'LSP: references', buffer} n '<Leader>lR' (vim.lsp.buf.references) {'LSP: references', buffer}
n '<Leader>lt' (vim.lsp.buf.type_definition) {'LSP: type definition', buffer} n '<Leader>lt' (vim.lsp.buf.type_definition) {'LSP: type definition', buffer}
n '<leader>lr' (vim.lsp.buf.rename) {'LSP: rename identifier', buffer} n '<leader>lr' (vim.lsp.buf.rename) {'LSP: rename identifier', buffer}
nv '<leader>la' (vim.lsp.buf.code_action) {'LSP: code actions', buffer} nv '<leader>la' (vim.lsp.buf.code_action) {'LSP: code actions', buffer}
n '<leader>lf' (format) {'LSP: format file', buffer} n '<leader>lf' (format) {'LSP: format file', buffer}
v '<leader>lf' (format_selection) {'LSP: format file', buffer} v '<leader>lf' (format_selection) {'LSP: format file', buffer}
n '<leader>wa' (vim.lsp.buf.add_workspace_folder) {'LSP: add workspace folder', buffer} n '<leader>wa' (vim.lsp.buf.add_workspace_folder) {'LSP: add workspace folder', buffer}
n '<leader>wr' (vim.lsp.buf.remove_workspace_folder) {'LSP: remove workspace folder', buffer} n '<leader>wr' (vim.lsp.buf.remove_workspace_folder) {'LSP: remove workspace folder', buffer}
n '<leader>wl' (workspaces_list) {'LSP: list workspace folders', buffer} n '<leader>wl' (workspaces_list) {'LSP: list workspace folders', buffer}
end end
vim.api.nvim_create_autocmd('LspAttach', { vim.api.nvim_create_autocmd('LspAttach', {
group = group, group = group,
callback = setup_lsp_keymaps callback = setup_lsp_keymaps
}) })
end end

View file

@ -3,27 +3,27 @@ local M = {}
function M.normalize() function M.normalize()
local c = vim.fn.getpos '.' local c = vim.fn.getpos '.'
local s = get_visual() local s = get_visual()
local max = 0 local max = 0
for line = s.sr, s.er do for line = s.sr, s.er do
local indent = vim.fn.indent(line) local indent = vim.fn.indent(line)
max = indent > max and indent or max max = indent > max and indent or max
end end
for line = s.sr, s.er do for line = s.sr, s.er do
local content = vim.fn.getline(line) local content = vim.fn.getline(line)
if content:len() > 0 then if content:len() > 0 then
local current = vim.fn.indent(line) local current = vim.fn.indent(line)
if current ~= max then if current ~= max then
local new = string.rep(' ', max - current) local new = string.rep(' ', max - current)
vim.fn.setline(line, new .. content) vim.fn.setline(line, new .. content)
end end
end end
end end
vim.fn.setpos('.', c) vim.fn.setpos('.', c)
end end
return M return M

View file

@ -4,14 +4,14 @@ local path = data .. '/lazy/lazy.nvim'
-- Bootstrap -- Bootstrap
if not vim.uv.fs_stat(path) then if not vim.uv.fs_stat(path) then
vim.fn.system { vim.fn.system {
'git', 'git',
'clone', 'clone',
'--filter=blob:none', '--filter=blob:none',
'https://github.com/folke/lazy.nvim.git', 'https://github.com/folke/lazy.nvim.git',
'--branch=stable', '--branch=stable',
path, path,
} }
end end
vim.opt.rtp:prepend(path) vim.opt.rtp:prepend(path)

View file

@ -1,42 +1,47 @@
local g, opt = vim.g, vim.opt local g, opt = vim.g, vim.opt
g.mapleader = [[ ]] -- use space for leader
g.maplocalleader = [[\]] -- use backslash for local leader
-- Providers -- Providers
g.loaded_python3_provider = 0 g.loaded_python3_provider = 0
g.loaded_ruby_provider = 0 g.loaded_ruby_provider = 0
g.loaded_perl_provider = 0 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
opt.tabstop = 2 -- 1 tab = 2 spaces opt.shiftwidth = 2 -- shift 2 spaces when tab
opt.shiftwidth = 2 -- Shift 2 spaces when tab opt.smartindent = true -- autoindent new lines
opt.smartindent = true -- Autoindent new lines opt.expandtab = false -- use spaces instead of tabs
opt.expandtab = true -- Use spaces instead of tabs opt.tabstop = 2 -- 1 tab = 2 spaces
-- UI -- UI
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 = '│·',
extends = '',
precedes = '',
} }
-- Additional filetypes -- Additional filetypes
vim.filetype.add { vim.filetype.add {
extension = { extension = {
mdx = 'mdx', mdx = 'mdx',
typ = 'typst', typ = 'typst',
purs = 'purescript', purs = 'purescript',
nu = 'nu', nu = 'nu',
} }
} }

View file

@ -6,374 +6,374 @@ local nv = map { 'n', 'v' }
---@type LazyPluginSpec[] ---@type LazyPluginSpec[]
return { return {
-- Theme -- Theme
{ {
'rebelot/kanagawa.nvim', 'rebelot/kanagawa.nvim',
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',
dependencies = { dependencies = {
'nvim-tree/nvim-web-devicons', 'nvim-tree/nvim-web-devicons',
}, },
config = true, config = true,
}, },
-- Fuzzy search -- Fuzzy search
{ {
'nvim-telescope/telescope.nvim', 'nvim-telescope/telescope.nvim',
branch = '0.1.x', 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: files' n '<leader>ff' (builtin.find_files) 'Telescope: files'
n '<leader>fb' (builtin.buffers) 'Telescope: buffers' n '<leader>fb' (builtin.buffers) 'Telescope: buffers'
n '<leader>fg' (builtin.live_grep) 'Telescope: grep' n '<leader>fg' (builtin.live_grep) 'Telescope: grep'
n '<leader>fh' (builtin.help_tags) 'Telescope: docs' n '<leader>fh' (builtin.help_tags) 'Telescope: docs'
n '<Leader>fk' (builtin.keymaps) 'Telescope: keymaps' n '<Leader>fk' (builtin.keymaps) 'Telescope: keymaps'
n '<leader>fn' (ext.notify.notify) 'Telescope: notifications' n '<leader>fn' (ext.notify.notify) 'Telescope: notifications'
end, end,
}, },
-- Keymap hints -- Keymap hints
{ {
'folke/which-key.nvim', 'folke/which-key.nvim',
init = function() init = function()
vim.o.timeout = true vim.o.timeout = true
vim.o.timeoutlen = 300 vim.o.timeoutlen = 300
end, end,
config = true config = true
}, },
-- Treesitter -- Treesitter
{ {
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate', build = ':TSUpdate',
dependencies = { dependencies = {
'nvim-treesitter/nvim-treesitter-textobjects' 'nvim-treesitter/nvim-treesitter-textobjects'
}, },
config = function() config = function()
local configs = require 'nvim-treesitter.configs' local configs = require 'nvim-treesitter.configs'
configs.setup { configs.setup {
modules = {}, modules = {},
auto_install = false, auto_install = false,
sync_install = false, sync_install = false,
ignore_install = {}, ignore_install = {},
ensure_installed = { ensure_installed = {
-- neovim -- neovim
'vimdoc', 'lua', 'query', 'fennel', 'vimdoc', 'lua', 'query', 'fennel',
-- nix -- nix
'nix', 'nix',
-- data -- data
'json', 'xml', 'yaml', 'toml', 'json', 'xml', 'yaml', 'toml',
-- 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',
-- python -- python
'python', 'python',
-- systems -- systems
'rust', 'c', 'rust', 'c',
-- webdev -- webdev
'html', 'css', 'scss', 'javascript', 'jsdoc', 'typescript', 'tsx', 'astro', 'svelte', 'html', 'css', 'scss', 'javascript', 'jsdoc', 'typescript', 'tsx', 'astro', 'svelte',
-- haskell -- haskell
'haskell', 'haskell',
}, },
highlight = { enable = true }, highlight = { enable = true },
indent = { enable = true }, indent = { enable = true },
incremental_selection = { incremental_selection = {
enable = true, enable = true,
keymaps = { keymaps = {
node_incremental = 'v', node_incremental = 'v',
node_decremental = 'V', node_decremental = 'V',
}, },
}, },
textobjects = { textobjects = {
select = { select = {
enable = true, enable = true,
keymaps = { keymaps = {
['af'] = '@function.outer', ['af'] = '@function.outer',
['if'] = '@function.inner', ['if'] = '@function.inner',
['a?'] = '@conditional.outer', ['a?'] = '@conditional.outer',
['i?'] = '@conditional.inner', ['i?'] = '@conditional.inner',
} }
}, },
move = { move = {
enable = true, enable = true,
goto_next_start = { goto_next_start = {
[']f'] = '@function.outer', [']f'] = '@function.outer',
}, },
goto_previous_start = { goto_previous_start = {
['[f'] = '@function.outer', ['[f'] = '@function.outer',
} }
} }
} }
} }
end, end,
init = function() init = function()
local lang = vim.treesitter.language local lang = vim.treesitter.language
lang.register('markdown', 'mdx') lang.register('markdown', 'mdx')
lang.register('markdown', 'lhaskell') lang.register('markdown', 'lhaskell')
end, end,
}, },
-- Configure LSP -- Configure LSP
{ {
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
config = function() config = function()
local lsp = require 'lspconfig' local lsp = require 'lspconfig'
local cmp = require 'cmp_nvim_lsp' local cmp = require 'cmp_nvim_lsp'
lsp.nixd.setup { lsp.nixd.setup {
single_file_support = true, single_file_support = true,
capabilities = cmp.default_capabilities(), capabilities = cmp.default_capabilities(),
} }
lsp.lua_ls.setup { lsp.lua_ls.setup {
single_file_support = true, single_file_support = true,
capabilities = cmp.default_capabilities(), capabilities = cmp.default_capabilities(),
} }
local signs = { local signs = {
Error = "", Error = "",
Warn = "", Warn = "",
Hint = "", Hint = "",
Info = "󰙎", Info = "󰙎",
} }
for sign, text in pairs(signs) do for sign, text in pairs(signs) do
local name = 'DiagnosticSign' .. sign local name = 'DiagnosticSign' .. sign
vim.fn.sign_define(name, { text = text, texthl = name }) vim.fn.sign_define(name, { text = text, texthl = name })
end end
end, end,
}, },
-- Notifications -- Notifications
{ {
'rcarriga/nvim-notify', 'rcarriga/nvim-notify',
config = function() config = function()
vim.notify = require 'notify' vim.notify = require 'notify'
end end
}, },
-- Project errors -- Project errors
{ {
"folke/trouble.nvim", "folke/trouble.nvim",
config = function () config = function()
local trouble = require 'trouble' local trouble = require 'trouble'
n '<leader>tt' '<cmd>Trouble diagnostics toggle<cr>' 'Trouble: Diagnostics' n '<leader>tt' '<cmd>Trouble diagnostics toggle<cr>' 'Trouble: Diagnostics'
n '<leader>tT' '<cmd>Trouble diagnostics toggle filter.buf=0<cr>' 'Trouble: Diagnostics (buffer)' n '<leader>tT' '<cmd>Trouble diagnostics toggle filter.buf=0<cr>' 'Trouble: Diagnostics (buffer)'
n '<leader>ts' '<cmd>Trouble symbols toggle focus=false<cr>' 'Trouble: Symbols' n '<leader>ts' '<cmd>Trouble symbols toggle focus=false<cr>' 'Trouble: Symbols'
-- n '<leader>cl' '<cmd>Trouble lsp toggle focus=false win.position=right<cr>' 'LSP Definitions / references / ... (Trouble)' -- n '<leader>cl' '<cmd>Trouble lsp toggle focus=false win.position=right<cr>' 'LSP Definitions / references / ... (Trouble)'
-- n '<leader>xL' '<cmd>Trouble loclist toggle<cr>' 'Location List (Trouble)' -- n '<leader>xL' '<cmd>Trouble loclist toggle<cr>' 'Location List (Trouble)'
-- n '<leader>xQ' '<cmd>Trouble qflist toggle<cr>' 'Quickfix List (Trouble)' -- n '<leader>xQ' '<cmd>Trouble qflist toggle<cr>' 'Quickfix List (Trouble)'
trouble.setup {} trouble.setup {}
end, end,
}, },
-- Breadcrumbs -- Breadcrumbs
{ {
'Bekaboo/dropbar.nvim', 'Bekaboo/dropbar.nvim',
-- dependencies = { -- dependencies = {
-- { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' } -- { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }
-- } -- }
}, },
{ {
"tris203/precognition.nvim", 'tris203/precognition.nvim',
config = function() config = function()
local pc = require 'precognition' local pc = require 'precognition'
nv '<leader>p' (pc.toggle) "Precognition: toggle" nv '<leader>p' (pc.toggle) 'Precognition: toggle'
pc.setup { pc.setup {
startVisible = false, startVisible = false,
} }
end, end,
}, },
-- Git - file hunks -- Git - file hunks
{ {
'lewis6991/gitsigns.nvim', 'lewis6991/gitsigns.nvim',
config = function() config = function()
local gs = require 'gitsigns' local gs = require 'gitsigns'
gs.setup { gs.setup {
on_attach = function() on_attach = function()
n '<Leader>hp' (gs.preview_hunk) 'Hunk: preview' n '<Leader>hp' (gs.preview_hunk) 'Hunk: preview'
n '<Leader>hs' (gs.stage_hunk) 'Hunk: stage' n '<Leader>hs' (gs.stage_hunk) 'Hunk: stage'
n '<Leader>hu' (gs.undo_stage_hunk) 'Hunk: unstage' n '<Leader>hu' (gs.undo_stage_hunk) 'Hunk: unstage'
n '<Leader>hr' (gs.reset_hunk) 'Hunk: reset' n '<Leader>hr' (gs.reset_hunk) 'Hunk: reset'
n '<leader>hS' (gs.stage_buffer) 'Hunk: buffer stage' n '<leader>hS' (gs.stage_buffer) 'Hunk: buffer stage'
n '<leader>hR' (gs.reset_buffer) 'Hunk: buffer reset' n '<leader>hR' (gs.reset_buffer) 'Hunk: buffer reset'
n '<leader>hd' (gs.toggle_deleted) 'Hunk: show deleted' n '<leader>hd' (gs.toggle_deleted) 'Hunk: show deleted'
end end
} }
end, end,
}, },
-- Git - project diff -- Git - project diff
{ {
'sindrets/diffview.nvim', 'sindrets/diffview.nvim',
dependencies = { dependencies = {
'nvim-lua/plenary.nvim', 'nvim-lua/plenary.nvim',
'nvim-tree/nvim-web-devicons', 'nvim-tree/nvim-web-devicons',
}, },
config = function() config = function()
local lib = require 'diffview.lib' local lib = require 'diffview.lib'
local function toggle(name) local function toggle(name)
return function() return function()
if not next(lib.views) then if not next(lib.views) then
vim.cmd(name) vim.cmd(name)
else else
vim.cmd 'DiffviewClose' vim.cmd 'DiffviewClose'
end end
end end
end end
n '<Leader>gd' (toggle 'DiffviewOpen') 'Git: Diff' n '<Leader>gd' (toggle 'DiffviewOpen') 'Git: Diff'
n '<Leader>gh' (toggle 'DiffviewFileHistory') 'Git: History' n '<Leader>gh' (toggle 'DiffviewFileHistory') 'Git: History'
end end
}, },
-- Color hints -- Color hints
{ {
'NvChad/nvim-colorizer.lua', 'NvChad/nvim-colorizer.lua',
ft = { 'css', 'scss' }, ft = { 'css', 'scss' },
config = true, config = true,
}, },
-- { -- {
-- dir = '~/Desktop/disasm.nvim', -- dir = '~/Desktop/disasm.nvim',
-- ft = { 'c' }, -- ft = { 'c' },
-- config = function() -- config = function()
-- local disasm = require 'disasm' -- local disasm = require 'disasm'
-- --
-- n '<Leader>a' (disasm.disassemble) 'Disasm: Disassemble' -- n '<Leader>a' (disasm.disassemble) 'Disasm: Disassemble'
-- n '<Leader>Af' (disasm.disassemble_full) 'Disasm: Disassemble full' -- n '<Leader>Af' (disasm.disassemble_full) 'Disasm: Disassemble full'
-- n '<Leader>Ac' (disasm.reconfigure) 'Disasm: Configure' -- n '<Leader>Ac' (disasm.reconfigure) 'Disasm: Configure'
-- n '<Leader>AC' (disasm.save_config) 'Disasm: Save config' -- n '<Leader>AC' (disasm.save_config) 'Disasm: Save config'
-- --
-- disasm.setup() -- disasm.setup()
-- end -- end
-- }, -- },
-- Completion -- Completion
{ {
'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',
}, },
config = require 'config.plugins.nvim-cmp' config = require 'config.plugins.nvim-cmp'
}, },
-- Debugger adapter support -- Debugger adapter support
{ {
'mfussenegger/nvim-dap', 'mfussenegger/nvim-dap',
dependencies = { dependencies = {
'nvim-neotest/nvim-nio', 'nvim-neotest/nvim-nio',
'rcarriga/nvim-dap-ui', 'rcarriga/nvim-dap-ui',
}, },
config = function() config = function()
local dap = require 'dap' local dap = require 'dap'
local ui = require 'dapui' local ui = require 'dapui'
n '<F5>' (dap.continue) 'Debugger: continue' n '<F5>' (dap.continue) 'Debugger: continue'
n '<F10>' (dap.step_over) 'Debugger: step over' n '<F10>' (dap.step_over) 'Debugger: step over'
n '<F11>' (dap.step_into) 'Debugger: step into' n '<F11>' (dap.step_into) 'Debugger: step into'
n '<F12>' (dap.step_out) 'Debugger: step out' n '<F12>' (dap.step_out) 'Debugger: step out'
n '<leader>db' (dap.toggle_breakpoint) 'Debugger: toggle breakpoint' n '<leader>db' (dap.toggle_breakpoint) 'Debugger: toggle breakpoint'
n '<leader>du' (ui.toggle) 'Debugger: toggle UI' n '<leader>du' (ui.toggle) 'Debugger: toggle UI'
nv '<leader>de' (ui.eval) 'Debugger: eval' nv '<leader>de' (ui.eval) 'Debugger: eval'
-- vim.api.nvim_set_hl(0, 'DapBreakpoint', { ctermbg = 0, fg = '#993939', bg = '#31353f' }) -- vim.api.nvim_set_hl(0, 'DapBreakpoint', { ctermbg = 0, fg = '#993939', bg = '#31353f' })
-- vim.api.nvim_set_hl(0, 'DapLogPoint', { ctermbg = 0, fg = '#61afef', bg = '#31353f' }) -- vim.api.nvim_set_hl(0, 'DapLogPoint', { ctermbg = 0, fg = '#61afef', bg = '#31353f' })
-- vim.api.nvim_set_hl(0, 'DapStopped', { ctermbg = 0, fg = '#98c379', bg = '#31353f' }) -- vim.api.nvim_set_hl(0, 'DapStopped', { ctermbg = 0, fg = '#98c379', bg = '#31353f' })
-- --
-- vim.fn.sign_define('DapBreakpoint', { text='', texthl='DapBreakpoint', linehl='DapBreakpoint', numhl='DapBreakpoint' }) -- vim.fn.sign_define('DapBreakpoint', { text='', texthl='DapBreakpoint', linehl='DapBreakpoint', numhl='DapBreakpoint' })
-- vim.fn.sign_define('DapBreakpointCondition', { text='ﳁ', texthl='DapBreakpoint', linehl='DapBreakpoint', numhl='DapBreakpoint' }) -- vim.fn.sign_define('DapBreakpointCondition', { text='ﳁ', texthl='DapBreakpoint', linehl='DapBreakpoint', numhl='DapBreakpoint' })
-- vim.fn.sign_define('DapBreakpointRejected', { text='', texthl='DapBreakpoint', linehl='DapBreakpoint', numhl= 'DapBreakpoint' }) -- vim.fn.sign_define('DapBreakpointRejected', { text='', texthl='DapBreakpoint', linehl='DapBreakpoint', numhl= 'DapBreakpoint' })
-- vim.fn.sign_define('DapLogPoint', { text='', texthl='DapLogPoint', linehl='DapLogPoint', numhl= 'DapLogPoint' }) -- vim.fn.sign_define('DapLogPoint', { text='', texthl='DapLogPoint', linehl='DapLogPoint', numhl= 'DapLogPoint' })
-- vim.fn.sign_define('DapStopped', { text='', texthl='DapStopped', linehl='DapStopped', numhl= 'DapStopped' }) -- vim.fn.sign_define('DapStopped', { text='', texthl='DapStopped', linehl='DapStopped', numhl= 'DapStopped' })
ui.setup() ui.setup()
dap.listeners.after.event_initialized["dapui_config"] = ui.open dap.listeners.after.event_initialized["dapui_config"] = ui.open
dap.listeners.after.event_terminated["dapui_config"] = ui.close dap.listeners.after.event_terminated["dapui_config"] = ui.close
dap.listeners.before.event_exited["dapui_config"] = ui.close dap.listeners.before.event_exited["dapui_config"] = ui.close
end, end,
}, },
-- Tools for Neovim -- Tools for Neovim
{ {
'folke/lazydev.nvim', 'folke/lazydev.nvim',
ft = 'lua', ft = 'lua',
opts = { opts = {
library = { library = {
'lazy.nvim', 'lazy.nvim',
}, 'rustaceanvim',
}, 'haskell-tools.nvim',
}, },
},
},
-- Tools for Rust -- Tools for Rust
{ {
'mrcjkb/rustaceanvim', 'mrcjkb/rustaceanvim',
version = '^3', version = '^4',
ft = { 'rust' }, ft = { 'rust' },
init = function() init = require 'config.plugins.rustaceanvim',
require 'config.plugins.rustaceanvim' },
end
},
-- Tools for Haskell -- Tools for Haskell
{ {
'mrcjkb/haskell-tools.nvim', 'mrcjkb/haskell-tools.nvim',
version = '^3', version = '^3',
ft = { 'haskell', 'lhaskell', 'cabal', 'cabalproject' }, ft = { 'haskell', 'lhaskell', 'cabal', 'cabalproject' },
dependencies = { dependencies = {
'nvim-lua/plenary.nvim', 'nvim-lua/plenary.nvim',
'nvim-telescope/telescope.nvim', 'nvim-telescope/telescope.nvim',
}, },
init = require 'config.plugins.haskell-tools' init = require 'config.plugins.haskell-tools'
}, },
} }

View file

@ -5,29 +5,29 @@ local n = map 'n'
---@param buffer number ---@param buffer number
---@param ht HaskellTools ---@param ht HaskellTools
local function on_attach(_, buffer, ht) local function on_attach(_, buffer, ht)
n '<leader>hc' (vim.lsp.codelens.run) {'Run codelens', buffer} n '<leader>hc' (vim.lsp.codelens.run) { 'Run codelens', buffer }
n '<leader>hs' (ht.hoogle.hoogle_signature) {'Hoogle: search', buffer} n '<leader>hs' (ht.hoogle.hoogle_signature) { 'Hoogle: search', buffer }
n '<leader>he' (ht.lsp.buf_eval_all) {'Haskell: eval all', buffer} n '<leader>he' (ht.lsp.buf_eval_all) { 'Haskell: eval all', buffer }
local function repl_file() local function repl_file()
local name = vim.api.nvim_buf_get_name(0) local name = vim.api.nvim_buf_get_name(0)
ht.repl.toggle(name) ht.repl.toggle(name)
end end
n '<leader>rf' (repl_file) 'Repl: Toggle GHCi for the current buffer' n '<leader>rf' (repl_file) 'Repl: Toggle GHCi for the current buffer'
n '<leader>rr' (ht.repl.toggle) {'Repl: Toggle GHCi for the current package', buffer} n '<leader>rr' (ht.repl.toggle) { 'Repl: Toggle GHCi for the current package', buffer }
n '<leader>rq' (ht.repl.quit) {'Repl: Quit', buffer} n '<leader>rq' (ht.repl.quit) { 'Repl: Quit', buffer }
-- Detect nvim-dap launch configurations -- Detect nvim-dap launch configurations
-- (requires nvim-dap and haskell-debug-adapter) -- (requires nvim-dap and haskell-debug-adapter)
-- ht.dap.discover_configurations(bufnr) -- ht.dap.discover_configurations(bufnr)
end end
---@type HTConfig ---@type HTConfig
local config = { local config = {
hls = { on_attach = on_attach } hls = { on_attach = on_attach }
} }
return function() return function()
vim.g.haskell_tools = config vim.g.haskell_tools = config
end end

View file

@ -1,52 +1,42 @@
-- Reference: https://github.com/hrsh7th/nvim-cmp#recommended-configuration -- Reference: https://github.com/hrsh7th/nvim-cmp#recommended-configuration
return function() return function()
local cmp = require "cmp" local cmp = require "cmp"
cmp.setup { cmp.setup {
snippet = { snippet = {
expand = function(args) expand = function(args)
vim.snippet.expand(args.body) vim.snippet.expand(args.body)
end, end,
}, },
window = { window = {
completion = cmp.config.window.bordered(), completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(),
}, },
mapping = cmp.mapping.preset.insert { mapping = cmp.mapping.preset.insert {
-- ['<Tab>'] = cmp.mapping(function(fallback) ['<C-b>'] = cmp.mapping.scroll_docs(-4),
-- if cmp.visible() then ['<C-f>'] = cmp.mapping.scroll_docs(4),
-- cmp.select_next_item() ['<C-CR>'] = cmp.mapping.complete(),
-- elseif vim.snippet.jumpable(1) then ['<C-e>'] = cmp.mapping.abort(),
-- vim.snippet.jump(1) ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
-- else },
-- fallback() sources = cmp.config.sources({ { name = 'nvim_lsp' } }, { { name = 'buffer' } })
-- end }
-- end, { 'i', 's' }),
-- And something similar for vim.snippet.jump(-1)
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-CR>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
},
sources = cmp.config.sources({{ name = 'nvim_lsp' }}, {{ name = 'buffer' }})
}
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({ '/', '?' }, { cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline(), mapping = cmp.mapping.preset.cmdline(),
sources = { sources = {
{ name = 'buffer' } { name = 'buffer' }
} }
}) })
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', { cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(), mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'path' } { name = 'path' }
}, { }, {
{ name = 'cmdline' } { name = 'cmdline' }
}) })
}) })
end end

View file

@ -2,36 +2,20 @@ local map = require 'config.helpers.keymap'
local n = map 'n' local n = map 'n'
vim.g.rustaceanvim = function() local function get_opts()
local mason = require 'mason-registry' local tools = require 'rustaceanvim'
local tools = require 'rustaceanvim'
local config = require 'rustaceanvim.config'
local lsp_root = mason.get_package('codelldb'):get_install_path() .. '/extension/' ---@type RustaceanOpts
local lsp_path = lsp_root .. 'adapter/codelldb' return {
local lib_path = lsp_root .. 'lldb/lib/liblldb.so' server = {
on_attach = function(_, bufnr)
---@type RustaceanOpts n '<C-b>' (tools.hover_actions.hover_actions) { buffer = bufnr }
return { n '<Leader>a' (tools.code_action_group.code_action_group) { buffer = bufnr }
server = { end,
on_attach = function(_, bufnr) },
n '<C-b>' (tools.hover_actions.hover_actions) {buffer=bufnr} }
n '<Leader>a' (tools.code_action_group.code_action_group) {buffer=bufnr} end
end,
}, return function()
default_settings = { vim.g.rustaceanvim = get_opts
['rust-analyzer'] = {
-- checkOnSave = {
-- allFeatures = true,
-- overrideCommand = {
-- 'cargo', 'clippy', '--workspace', '--message-format=json',
-- '--all-targets', '--all-features'
-- }
-- },
},
},
dap = {
adapter = config.get_codelldb_adapter(lsp_path, lib_path),
},
}
end end

View file

@ -5,14 +5,14 @@ require 'config.autocmd'
-- Are we inside Neovide? -- Are we inside Neovide?
if vim.g.neovide then if vim.g.neovide then
require 'config.neovide' require 'config.neovide'
end end
-- Try load package manager -- Try load package manager
local ok, err = pcall(require, 'config.manager') local ok, err = pcall(require, 'config.manager')
if not ok then if not ok then
vim.schedule(function() vim.schedule(function()
vim.notify(err, vim.log.levels.ERROR) vim.notify(err, vim.log.levels.ERROR)
end) end)
end end