nvim: Stuff

This commit is contained in:
2025-08-02 12:00:01 +02:00
parent e63b1fd2e6
commit 594b3d667b
8 changed files with 696 additions and 572 deletions

View File

@ -5,60 +5,67 @@ vim.g.localleader = "\\"
-- Install Lazy -- Install Lazy
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git" local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({ vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" }, { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" }, { out, "WarningMsg" },
{ "\nPress any key to exit..." }, { "\nPress any key to exit..." },
}, true, {}) }, true, {})
vim.fn.getchar() vim.fn.getchar()
os.exit(1) os.exit(1)
end end
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
-- TODO: get colored renders working -- TODO: get colored renders working
vim.g.rustaceanvim = { vim.g.rustaceanvim = {
-- Plugin configuration -- Plugin configuration
tools = {}, tools = {
float_win_config = { border = 'rounded' },
},
-- LSP configuration -- LSP configuration
server = { server = {
on_attach = function(client, bufnr) on_attach = function(client, bufnr)
vim.keymap.set('n', '<leader>lg', pick_rust_target, vim.keymap.set('n', '<leader>lg', pick_rust_target,
{ desc = "Pick Target (Rust)", buffer = bufnr }) { desc = "Pick Target (Rust)", buffer = bufnr })
vim.keymap.set('n', "<leader>a", function() vim.cmd.RustLsp('codeAction') end, vim.keymap.set('n', "<leader>a", function() vim.cmd.RustLsp('codeAction') end,
{ desc = "Code Action (Rust)", buffer = bufnr }) { desc = "Code Action (Rust)", buffer = bufnr })
vim.keymap.set('n', "<leader>e", function() vim.cmd.RustLsp('renderDiagnostic', 'current') end, vim.keymap.set('n', "<leader>e", function() vim.cmd.RustLsp('renderDiagnostic', 'current') end,
{ desc = "Render Diagnostic", buffer = bufnr }) { desc = "Render Diagnostic", buffer = bufnr })
end, end,
default_settings = { default_settings = {
['rust-analyzer'] = { ['rust-analyzer'] = {
checkOnSave = { overrideCommand = "cargo check --message-format=json-diagnostic-rendered-ansi" }, checkOnSave = true,
}, check = {
}, overrideCommand = {
settings = function(project_root) "cargo", "check", "--message-format=json-diagnostic-rendered-ansi",
local ra = require('rustaceanvim.config.server') }
local settings = ra.load_rust_analyzer_settings(project_root, { },
settings_file_pattern = 'rust-analyzer.json' },
}) },
settings = function(project_root)
local ra = require('rustaceanvim.config.server')
local settings = ra.load_rust_analyzer_settings(project_root, {
settings_file_pattern = 'rust-analyzer.json'
})
-- override default target (if `set_rust_target` has been called) -- override default target (if `set_rust_target` has been called)
local rust_target = vim.g["rust-analyzer-target"] local rust_target = vim.g["rust-analyzer-target"]
if rust_target then if rust_target then
settings["rust-analyzer"]["cargo"] = { target = rust_target } settings["rust-analyzer"]["cargo"] = { target = rust_target }
end end
vim.g["rust-analyzer-target-test"] = settings vim.g["rust-analyzer-target-test"] = settings
return settings return settings
end, end,
}, },
-- DAP configuration -- DAP configuration
dap = {}, dap = {},
} }
@ -82,116 +89,125 @@ local language_servers = {
"wgsl_analyzer", "wgsl_analyzer",
} }
require("mason").setup({ require("mason").setup({
ui = { ui = {
icons = { icons = {
package_installed = "", package_installed = "",
package_pending = "", package_pending = "",
package_uninstalled = "", package_uninstalled = "",
}, },
}, },
ensure_installed = language_servers, ensure_installed = language_servers,
}) })
require("mason-lspconfig").setup() require("mason-lspconfig").setup {
automatic_enable = {
exclude = {
-- rust_analyzer is managed by rustaceanvim
"rust_analyzer",
}
}
}
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
for _,l in pairs(language_servers) do for _, l in pairs(language_servers) do
lspconfig[l].setup {} lspconfig[l].setup {}
end end
require('dapui').setup();
local compare = require "cmp.config.compare" local compare = require "cmp.config.compare"
require('cmp').setup.filetype({ "rust" }, { require('cmp').setup.filetype({ "rust" }, {
sorting = { sorting = {
priority_weight = 2, priority_weight = 2,
comparators = { comparators = {
-- deprioritize `.box`, `.mut`, etc. -- deprioritize `.box`, `.mut`, etc.
require("cmp-rust").deprioritize_postfix, require("cmp-rust").deprioritize_postfix,
-- deprioritize `Borrow::borrow` and `BorrowMut::borrow_mut` -- deprioritize `Borrow::borrow` and `BorrowMut::borrow_mut`
require("cmp-rust").deprioritize_borrow, require("cmp-rust").deprioritize_borrow,
-- deprioritize `Deref::deref` and `DerefMut::deref_mut` -- deprioritize `Deref::deref` and `DerefMut::deref_mut`
require("cmp-rust").deprioritize_deref, require("cmp-rust").deprioritize_deref,
-- deprioritize `Into::into`, `Clone::clone`, etc. -- deprioritize `Into::into`, `Clone::clone`, etc.
require("cmp-rust").deprioritize_common_traits, require("cmp-rust").deprioritize_common_traits,
compare.offset, compare.offset,
compare.exact, compare.exact,
compare.score, compare.score,
--compare.recently_used, --compare.recently_used,
compare.locality, compare.locality,
compare.sort_text, compare.sort_text,
compare.length, compare.length,
compare.order, compare.order,
}, },
}, },
}) })
-- Format file on save -- Format file on save
vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]] vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]]
-- Completion Plugin Setup -- Completion Plugin Setup
local cmp = require'cmp' local cmp = require 'cmp'
cmp.setup({ cmp.setup({
-- Enable LSP snippets -- Enable LSP snippets
snippet = { snippet = {
expand = function(args) expand = function(args)
vim.fn["vsnip#anonymous"](args.body) vim.fn["vsnip#anonymous"](args.body)
end, end,
}, },
mapping = { mapping = {
['<C-p>'] = cmp.mapping.select_prev_item(), ['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(), ['<C-n>'] = cmp.mapping.select_next_item(),
-- Add tab support -- Add tab support
['<S-Tab>'] = cmp.mapping.select_prev_item(), ['<S-Tab>'] = cmp.mapping.select_prev_item(),
['<Tab>'] = cmp.mapping.select_next_item(), ['<Tab>'] = cmp.mapping.select_next_item(),
['<C-S-f>'] = cmp.mapping.scroll_docs(-4), ['<C-S-f>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4), ['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(), ['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(), ['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({ ['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert, behavior = cmp.ConfirmBehavior.Insert,
select = true, select = true,
}) })
}, },
-- Installed sources: -- Installed sources:
sources = { sources = {
{ name = 'path' }, -- file paths { name = 'path' }, -- file paths
{ name = 'nvim_lsp', keyword_length = 3 }, -- from language server { name = 'nvim_lsp', keyword_length = 3 }, -- from language server
{ name = 'nvim_lsp_signature_help'}, -- display function signatures with current parameter emphasized { name = 'nvim_lsp_signature_help' }, -- display function signatures with current parameter emphasized
{ name = 'nvim_lua', keyword_length = 2 }, -- complete neovim's Lua runtime API such vim.lsp.* { name = 'nvim_lua', keyword_length = 2 }, -- complete neovim's Lua runtime API such vim.lsp.*
{ name = 'buffer', keyword_length = 2 }, -- source current buffer { name = 'buffer', keyword_length = 2 }, -- source current buffer
{ name = 'vsnip', keyword_length = 2 }, -- nvim-cmp source for vim-vsnip { name = 'vsnip', keyword_length = 2 }, -- nvim-cmp source for vim-vsnip
{ name = 'calc'}, -- source for math calculation { name = 'calc' }, -- source for math calculation
}, },
window = { window = {
completion = cmp.config.window.bordered(), completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(),
}, },
formatting = { formatting = {
fields = {'menu', 'abbr', 'kind'}, fields = { 'menu', 'abbr', 'kind' },
format = function(entry, item) format = function(entry, item)
local menu_icon ={ local menu_icon = {
nvim_lsp = 'λ', nvim_lsp = 'λ',
vsnip = '', vsnip = '',
buffer = 'Ω', buffer = 'Ω',
path = '🖫', path = '🖫',
} }
item.menu = menu_icon[entry.source.name] item.menu = menu_icon[entry.source.name]
return item return item
end, end,
}, },
}) })
-- Treesitter Plugin Setup -- Treesitter Plugin Setup
require('nvim-treesitter.configs').setup { require('nvim-treesitter.configs').setup {
ensure_installed = { "lua", "rust", "toml" }, ensure_installed = { "lua", "rust", "toml" },
auto_install = true, auto_install = true,
highlight = { highlight = {
enable = true, enable = true,
additional_vim_regex_highlighting=false, additional_vim_regex_highlighting = false,
}, },
ident = { enable = true }, ident = { enable = true },
rainbow = { rainbow = {
enable = true, enable = true,
extended_mode = true, extended_mode = true,
max_file_lines = nil, max_file_lines = nil,
} }
} }

View File

@ -4,115 +4,115 @@ local codelldb_bin = "/usr/bin/codelldb"
-- Rust, C++, C -- Rust, C++, C
dap.adapters.codelldb = { dap.adapters.codelldb = {
type = 'server', type = 'server',
port = "${port}", port = "${port}",
executable = { executable = {
command = codelldb_bin, command = codelldb_bin,
args = {"--port", "${port}"}, args = { "--port", "${port}" },
} }
} }
local function get_default_rust_program_path() local function get_default_rust_program_path()
local workspace = vim.fn.getcwd() local workspace = vim.fn.getcwd()
local program_name = vim.fn.fnamemodify(workspace, ":t") local program_name = vim.fn.fnamemodify(workspace, ":t")
return workspace .. '/target/debug/' .. program_name return workspace .. '/target/debug/' .. program_name
end end
dap.configurations.cpp = { dap.configurations.cpp = {
{ {
port = 1234, port = 1234,
host = '127.0.0.1', host = '127.0.0.1',
name = "Attach to name", name = "Attach to name",
type = "codelldb", type = "codelldb",
request = "attach", request = "attach",
pid = function() pid = function()
-- Lets user enter the name of a running process instead of looking up the pid themselves -- Lets user enter the name of a running process instead of looking up the pid themselves
local name = vim.fn.input('Enter pidof name: ') local name = vim.fn.input('Enter pidof name: ')
local handle = io.popen("pidof " .. name) local handle = io.popen("pidof " .. name)
local pid = handle:read("*a") local pid = handle:read("*a")
handle:close() handle:close()
-- Trim the result -- Trim the result
pid = pid:match( "^%s*(.-)%s*$" ) pid = pid:match("^%s*(.-)%s*$")
return pid return pid
end, end,
stopOnEntry = true, stopOnEntry = true,
}, },
{ {
port = 1234, port = 1234,
host = '127.0.0.1', host = '127.0.0.1',
name = "Attach to PID", name = "Attach to PID",
type = "codelldb", type = "codelldb",
request = "attach", request = "attach",
pid = function() pid = function()
return tonumber(vim.fn.input('Enter PID: ')) return tonumber(vim.fn.input('Enter PID: '))
end, end,
stopOnEntry = true, stopOnEntry = true,
}, },
{ {
port = 1234, port = 1234,
host = '127.0.0.1', host = '127.0.0.1',
name = "Manually launch file", name = "Manually launch file",
type = "codelldb", type = "codelldb",
request = "launch", request = "launch",
program = function() program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end, end,
cwd = '${workspaceFolder}', cwd = '${workspaceFolder}',
stopOnEntry = true, stopOnEntry = true,
}, },
{ {
-- To debug programs that need to run as root you can run a remote lldb-server as root -- To debug programs that need to run as root you can run a remote lldb-server as root
-- sudo lldb-server platform --server --listen '*:1234' -- sudo lldb-server platform --server --listen '*:1234'
name = "Remote attach to name", name = "Remote attach to name",
type = "codelldb", type = "codelldb",
request = "attach", request = "attach",
pid = function() pid = function()
-- Lets user enter the name of a running process instead of looking up the pid themselves -- Lets user enter the name of a running process instead of looking up the pid themselves
local name = vim.fn.input('Enter pidof name: ') local name = vim.fn.input('Enter pidof name: ')
local handle = io.popen("pidof " .. name) local handle = io.popen("pidof " .. name)
local pid = handle:read("*a") local pid = handle:read("*a")
handle:close() handle:close()
-- Trim the result -- Trim the result
pid = pid:match( "^%s*(.-)%s*$" ) pid = pid:match("^%s*(.-)%s*$")
return pid return pid
end, end,
initCommands = { initCommands = {
"platform select remote-linux", "platform select remote-linux",
"platform connect connect://127.0.0.1:1234", "platform connect connect://127.0.0.1:1234",
"settings set target.inherit-env false", "settings set target.inherit-env false",
}, },
}, },
{ {
-- To debug programs that need to run as root you can run a remote lldb-server as root -- To debug programs that need to run as root you can run a remote lldb-server as root
-- sudo lldb-server platform --server --listen '*:1234' -- sudo lldb-server platform --server --listen '*:1234'
name = "Remote launch", name = "Remote launch",
type = "codelldb", type = "codelldb",
request = "launch", request = "launch",
program = function() program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end, end,
initCommands = { initCommands = {
"platform select remote-linux", "platform select remote-linux",
"platform connect connect://127.0.0.1:1234", "platform connect connect://127.0.0.1:1234",
"settings set target.inherit-env false", "settings set target.inherit-env false",
}, },
}, },
} }
dap.configurations.c = dap.configurations.cpp dap.configurations.c = dap.configurations.cpp
dap.configurations.rust = dap.configurations.cpp dap.configurations.rust = dap.configurations.cpp
-- Insert this config as a rust specific one before the C++ configs -- Insert this config as a rust specific one before the C++ configs
table.insert(dap.configurations.rust, 1, { table.insert(dap.configurations.rust, 1, {
port = 1234, port = 1234,
host = '127.0.0.1', host = '127.0.0.1',
name = "Launch Default Rust Program", name = "Launch Default Rust Program",
type = "codelldb", type = "codelldb",
request = "launch", request = "launch",
program = get_default_rust_program_path, program = get_default_rust_program_path,
cwd = '${workspaceFolder}', cwd = '${workspaceFolder}',
stopOnEntry = true, stopOnEntry = true,
}) })
-- Python -- Python

View File

@ -1,47 +1,132 @@
local telescope = require('telescope.builtin') local telescope = require('telescope.builtin')
local wk = require('which-key') local wk = require('which-key')
local harpoon = require("harpoon")
local telescope_conf = require("telescope.config").values
harpoon:setup()
vim.keymap.set('n', '<leader>f', telescope.find_files, { desc = "File picker" }) vim.keymap.set('n', '<leader>f', telescope.find_files, { desc = "File picker" })
vim.keymap.set('n', '<leader>g', telescope.live_grep, { desc = "Grep recursively" }) vim.keymap.set('n', '<leader>g', telescope.live_grep, { desc = "Grep recursively" })
vim.keymap.set('n', '<leader>b', telescope.buffers, { desc = "Buffer picker" }) vim.keymap.set('n', '<leader>b', telescope.buffers, { desc = "Buffer picker" })
vim.keymap.set('n', '<leader>?', telescope.help_tags, { desc = "Help tags picker" }) vim.keymap.set('n', '<leader>?', telescope.help_tags, { desc = "Help tags picker" })
vim.keymap.set('n', '<leader>s', telescope.treesitter, { desc = "Treesitter symbol picker" }) vim.keymap.set('n', '<leader>s', telescope.treesitter, { desc = "Treesitter symbol picker" })
vim.keymap.set('n', '<leader>j', telescope.jumplist, { desc = "Jumplist" })
vim.keymap.set('n', '<leader>u', ":TodoTelescope<Enter>", { desc = "Grep for TODOs" }) vim.keymap.set('n', '<leader>u', ":TodoTelescope<Enter>", { desc = "Grep for TODOs" })
vim.keymap.set('n', 'U', ":redo<Enter>", {}) vim.keymap.set('n', 'U', ":redo<Enter>", {})
vim.keymap.set('n', '<leader>p', ":b#<Enter>", { desc = "Go to last buffer" }) vim.keymap.set('n', '<leader>p', ":b#<Enter>", { desc = "Go to last buffer" })
local function toggle_telescope(harpoon_files)
local displayer = require("telescope.pickers.entry_display").create({
separator = " | ",
items = {
--{ width = 0.1 },
{ width = 0.9 },
}
})
local harpoons = {}
for _, item in ipairs(harpoon_files.items) do
table.insert(harpoons, {
filepath = item.value,
col = item.context.col,
row = item.context.row,
})
end
require("telescope.pickers").new({}, {
prompt_title = "Harpoon",
finder = require("telescope.finders").new_table({
results = harpoons,
entry_maker = function(entry)
--vim.print("mapping entry")
--vim.print(entry)
local filepath_with_row = string.format("%s:%d", entry.filepath, entry.row)
return {
-- Value to display. Required. type=any
--value = { "foo", entry.filepath, },
value = entry,
-- Whether to display the entry. Optional. type=bool
valid = true,
-- Optional. type=string|function
--display = entry.filepath,
display = function(entry)
return displayer({
-- NOTE: the number of elements must match the
-- configuration passed to `displayer` above
--{ "foobar" },
{ filepath_with_row }
})
end,
-- Used for filtering. Optional. type=string
ordinal = filepath_with_row,
-- File to open when pressing enter. Optional. type=string
filename = entry.filepath,
-- Buffer to open when pressing enter. Optional. type=number
-- bufnr = 0,
-- Line number of file/buffer to open. Optional. type=number
lnum = entry.row,
-- Line number of file/buffer to open. Optional. type=number
col = entry.row,
}
end
}),
previewer = telescope_conf.grep_previewer({}),
sorter = telescope_conf.generic_sorter({}),
}):find()
end
vim.keymap.set("n", "<leader>h", function() toggle_telescope(harpoon:list()) end,
{ desc = "Open harpoon window" })
vim.keymap.set("n", "<leader>H", function() harpoon:list():add() end,
{ desc = "Launch harpoon" })
-- Toggle previous & next buffers stored within Harpoon list
--vim.keymap.set("n", "<C-S-P>", function() harpoon:list():prev() end)
--vim.keymap.set("n", "<C-S-N>", function() harpoon:list():next() end)
-- Use LspAttach autocommand to only map the following keys -- Use LspAttach autocommand to only map the following keys
-- after the language server attaches to the current buffer -- after the language server attaches to the current buffer
vim.api.nvim_create_autocmd('LspAttach', { vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}), group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev) callback = function(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'
-- Buffer local mappings. -- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions -- See `:help vim.lsp.*` for documentation on any of the below functions
vim.keymap.set('n', '<leader>ld', telescope.lsp_definitions, { desc = "Show definitons", buffer = ev.buf }) vim.keymap.set('n', '<leader>ld', telescope.lsp_definitions, { desc = "Show definitons", buffer = ev.buf })
vim.keymap.set('n', '<leader>lr', telescope.lsp_references, { desc = "Show references", buffer = ev.buf }) vim.keymap.set('n', '<leader>lr', telescope.lsp_references, { desc = "Show references", buffer = ev.buf })
vim.keymap.set('n', '<leader>li', telescope.lsp_implementations, { desc = "Show implementations", buffer = ev.buf }) vim.keymap.set('n', '<leader>li', telescope.lsp_implementations,
vim.keymap.set('n', '<leader>lt', telescope.lsp_type_definitions, { desc = "Show type definitions", buffer = ev.buf }) { desc = "Show implementations", buffer = ev.buf })
vim.keymap.set('n', '<leader>le', telescope.diagnostics, { desc = "Show diagnostics", buffer = ev.buf }) vim.keymap.set('n', '<leader>lt', telescope.lsp_type_definitions,
vim.keymap.set('n', '<leader>ls', telescope.lsp_workspace_symbols, { desc = "Show workspace symbols", buffer = ev.buf }) { desc = "Show type definitions", buffer = ev.buf })
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = ev.buf }) vim.keymap.set('n', '<leader>le', telescope.diagnostics, { desc = "Show diagnostics", buffer = ev.buf })
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, { buffer = ev.buf }) vim.keymap.set('n', '<leader>ls', telescope.lsp_workspace_symbols,
vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, { desc = "Add workspace folder", buffer = ev.buf }) { desc = "Show workspace symbols", buffer = ev.buf })
vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, { desc = "Remove workspace folder", buffer = ev.buf }) vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = ev.buf })
vim.keymap.set('n', '<leader>wl', function() vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, { buffer = ev.buf })
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder,
end, { desc = "List workspace folders", buffer = ev.buf }) { desc = "Add workspace folder", buffer = ev.buf })
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, { desc = "Rename symbol", buffer = ev.buf }) vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder,
vim.keymap.set('n', "<leader>a", vim.lsp.buf.code_action, { desc = "Code Action", buffer = ev.buf }) { desc = "Remove workspace folder", buffer = ev.buf })
vim.keymap.set('n', '<leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, { desc = "List workspace folders", buffer = ev.buf })
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, { desc = "Rename symbol", buffer = ev.buf })
vim.keymap.set('n', "<leader>a", vim.lsp.buf.code_action, { desc = "Code Action", buffer = ev.buf })
wk.add({ wk.add({
{ "<leader>l", desc = "Language server stuff" }, { "<leader>l", desc = "Language server stuff" },
{ "<leader>w", desc = "Workspace stuff" }, { "<leader>w", desc = "Workspace stuff" },
}) })
end,
end,
}) })
--local rust_tools = require("rust-tools") --local rust_tools = require("rust-tools")

View File

@ -1,16 +1,16 @@
-- Bootstrap lazy.nvim -- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git" local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({ vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" }, { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" }, { out, "WarningMsg" },
{ "\nPress any key to exit..." }, { "\nPress any key to exit..." },
}, true, {}) }, true, {})
vim.fn.getchar() vim.fn.getchar()
os.exit(1) os.exit(1)
end end
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)

View File

@ -1,40 +1,40 @@
local opt = vim.opt local opt = vim.opt
-- Use system clipboard -- Use system clipboard
vim.opt.clipboard="unnamedplus" vim.opt.clipboard = "unnamedplus"
-- [[ Context ]] -- [[ Context ]]
opt.colorcolumn = '100' -- str: Show col for max line length opt.colorcolumn = '100' -- str: Show col for max line length
opt.number = true -- bool: Show line numbers opt.number = true -- bool: Show line numbers
opt.relativenumber = true -- bool: Show relative line numbers opt.relativenumber = true -- bool: Show relative line numbers
opt.scrolloff = 10 -- int: Min num lines of context opt.scrolloff = 10 -- int: Min num lines of context
opt.signcolumn = "yes" -- str: Show the sign column opt.signcolumn = "yes" -- str: Show the sign column
-- [[ Filetypes ]] -- [[ Filetypes ]]
opt.encoding = 'utf8' -- str: String encoding to use opt.encoding = 'utf8' -- str: String encoding to use
-- opt.fileencoding = 'utf8' -- str: File encoding to use -- opt.fileencoding = 'utf8' -- str: File encoding to use
vim.filetype.add({extension = {wgsl = "wgsl"}}) vim.filetype.add({ extension = { wgsl = "wgsl" } })
-- [[ Theme ]] -- [[ Theme ]]
opt.syntax = "ON" -- str: Allow syntax highlighting opt.syntax = "ON" -- str: Allow syntax highlighting
opt.termguicolors = true -- bool: If term supports ui color then enable opt.termguicolors = true -- bool: If term supports ui color then enable
-- [[ Search ]] -- [[ Search ]]
opt.ignorecase = true -- bool: Ignore case in search patterns opt.ignorecase = true -- bool: Ignore case in search patterns
opt.smartcase = true -- bool: Override ignorecase if search contains capitals opt.smartcase = true -- bool: Override ignorecase if search contains capitals
opt.incsearch = true -- bool: Use incremental search opt.incsearch = true -- bool: Use incremental search
opt.hlsearch = false -- bool: Highlight search matches opt.hlsearch = false -- bool: Highlight search matches
-- [[ Whitespace ]] -- [[ Whitespace ]]
-- opt.expandtab = true -- bool: Use spaces instead of tabs -- opt.expandtab = true -- bool: Use spaces instead of tabs
opt.shiftwidth = 4 -- num: Size of an indent opt.shiftwidth = 4 -- num: Size of an indent
opt.softtabstop = 4 -- num: Number of spaces tabs count for in insert mode opt.softtabstop = 4 -- num: Number of spaces tabs count for in insert mode
opt.tabstop = 4 -- num: Number of spaces tabs count for opt.tabstop = 4 -- num: Number of spaces tabs count for
opt.list = true -- show some whitespace opt.list = true -- show some whitespace
-- [[ Splits ]] -- [[ Splits ]]
opt.splitright = true -- bool: Place new window to right of current one opt.splitright = true -- bool: Place new window to right of current one
opt.splitbelow = true -- bool: Place new window below the current one opt.splitbelow = true -- bool: Place new window below the current one
--Set completeopt to have a better completion experience --Set completeopt to have a better completion experience
-- :help completeopt -- :help completeopt
@ -43,11 +43,10 @@ opt.splitbelow = true -- bool: Place new window below the current one
-- noselect: Do not select, force to select one from the menu -- noselect: Do not select, force to select one from the menu
-- shortness: avoid showing extra messages when using completion -- shortness: avoid showing extra messages when using completion
-- updatetime: set updatetime for CursorHold -- updatetime: set updatetime for CursorHold
vim.opt.completeopt = {'menuone', 'noselect', 'noinsert'} vim.opt.completeopt = { 'menuone', 'noselect', 'noinsert' }
vim.opt.shortmess = vim.opt.shortmess + { c = true} vim.opt.shortmess = vim.opt.shortmess + { c = true }
vim.api.nvim_set_option('updatetime', 300) vim.api.nvim_set_option('updatetime', 300)
-- Uncomment to enable treesitter folding by default -- Uncomment to enable treesitter folding by default
--vim.wo.foldmethod = 'expr' --vim.wo.foldmethod = 'expr'
--vim.wo.foldexpr = 'nvim_treesitter#foldexpr()' --vim.wo.foldexpr = 'nvim_treesitter#foldexpr()'

View File

@ -1,98 +1,122 @@
require("lazy").setup({ require("lazy").setup({
spec = { spec = {
-- install plugins -- install plugins
{ 'nvim-treesitter/nvim-treesitter' }, { 'nvim-treesitter/nvim-treesitter' },
{ 'ellisonleao/gruvbox.nvim' }, { 'ellisonleao/gruvbox.nvim' },
{ 'danilamihailov/beacon.nvim' }, { 'danilamihailov/beacon.nvim' },
{ 'nvim-lua/plenary.nvim' }, { 'nvim-lua/plenary.nvim' },
{ {
'folke/todo-comments.nvim', 'folke/todo-comments.nvim',
dependencies = { "nvim-lua/plenary.nvim" }, dependencies = { "nvim-lua/plenary.nvim" },
opts = { opts = {
keywords = { keywords = {
SAFETY = { SAFETY = {
icon = "", icon = "",
color = "warning", color = "warning",
alt = { "SOUNDNESS", "UNSAFE", "UNSOUND" }, alt = { "SOUNDNESS", "UNSAFE", "UNSOUND" },
}, },
INVARIANT = { INVARIANT = {
icon = "🦑", icon = "🦑",
color = "hint", color = "hint",
}, },
}, },
}, },
}, },
{ {
"folke/which-key.nvim", "folke/which-key.nvim",
event = "VeryLazy", event = "VeryLazy",
init = function() init = function()
vim.o.timeout = true vim.o.timeout = true
vim.o.timeoutlen = 300 vim.o.timeoutlen = 300
end, end,
opts = { opts = {
-- your configuration comes here -- your configuration comes here
-- or leave it empty to use the default settings -- or leave it empty to use the default settings
-- refer to the configuration section below -- refer to the configuration section below
}, },
}, },
{ 'rktjmp/fwatch.nvim' }, { 'rktjmp/fwatch.nvim' },
{ {
"folke/snacks.nvim", "folke/snacks.nvim",
priority = 1000, priority = 1000,
lazy = false, lazy = false,
opts = { opts = {
bigfile = { enabled = true }, bigfile = { enabled = true },
notifier = { enabled = true }, notifier = { enabled = true },
quickfile = { enabled = true }, quickfile = { enabled = true },
statuscolumn = { enabled = true }, statuscolumn = { enabled = true },
words = { enabled = true }, words = { enabled = true },
}, },
}, },
{
"folke/flash.nvim",
event = "VeryLazy",
---@type Flash.Config
opts = {},
-- stylua: ignore
keys = {
{ "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" },
{ "S", mode = { "n", "x", "o" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" },
{ "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" },
{ "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" },
{ "<c-s>", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" },
},
},
-- -- language server stuff -- -- language server stuff
{ 'williamboman/mason.nvim' }, { 'williamboman/mason.nvim' },
{ 'williamboman/mason-lspconfig.nvim' }, { 'williamboman/mason-lspconfig.nvim' },
{ 'neovim/nvim-lspconfig' }, { 'neovim/nvim-lspconfig' },
{ {
'mrcjkb/rustaceanvim', 'mrcjkb/rustaceanvim',
version = '^4', version = '^6',
lazy = false, -- This plugin is already lazy lazy = false, -- This plugin is already lazy
}, },
{ 'mfussenegger/nvim-dap' }, { 'mfussenegger/nvim-dap' },
{ 'rcarriga/nvim-dap-ui', dependencies = { 'mfussenegger/nvim-dap', 'nvim-neotest/nvim-nio' } },
{ 'theHamsta/nvim-dap-virtual-text' },
{ 'jay-babu/mason-nvim-dap.nvim' },
-- -- nushell support -- -- nushell support
-- --use { 'LhKipp/nvim-nu', run = function() vim.fn[':TSInstall nu'] end} } -- --use { 'LhKipp/nvim-nu', run = function() vim.fn[':TSInstall nu'] end} }
{ 'LhKipp/nvim-nu' }, { 'LhKipp/nvim-nu' },
-- -- Completion framework: -- -- Completion framework:
{ 'hrsh7th/nvim-cmp' }, { 'hrsh7th/nvim-cmp' },
-- -- LSP completion source: -- -- LSP completion source:
{ 'hrsh7th/cmp-nvim-lsp' }, { 'hrsh7th/cmp-nvim-lsp' },
-- -- Useful completion sources: -- -- Useful completion sources:
{ 'hrsh7th/cmp-nvim-lua' }, { 'hrsh7th/cmp-nvim-lua' },
{ 'hrsh7th/cmp-nvim-lsp-signature-help' }, { 'hrsh7th/cmp-nvim-lsp-signature-help' },
{ 'hrsh7th/cmp-vsnip' }, { 'hrsh7th/cmp-vsnip' },
{ 'hrsh7th/cmp-path' }, { 'hrsh7th/cmp-path' },
{ 'hrsh7th/cmp-buffer' }, { 'hrsh7th/cmp-buffer' },
{ 'hrsh7th/vim-vsnip' }, { 'hrsh7th/vim-vsnip' },
{ 'ryo33/nvim-cmp-rust' }, { 'ryo33/nvim-cmp-rust' },
{ 'nvim-telescope/telescope.nvim', branch = '0.1.x', {
dependencies = { 'nvim-lua/plenary.nvim' } 'nvim-telescope/telescope.nvim',
}, branch = '0.1.x',
dependencies = { 'nvim-lua/plenary.nvim' }
},
{
"ThePrimeagen/harpoon",
branch = "harpoon2",
dependencies = { "nvim-lua/plenary.nvim" }
},
-- -- status line -- -- status line
{ 'linrongbin16/lsp-progress.nvim' }, { 'linrongbin16/lsp-progress.nvim' },
{ 'nvim-lualine/lualine.nvim' }, { 'nvim-lualine/lualine.nvim' },
}, },
-- Configure any other settings here. See the documentation for more details. -- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins. -- colorscheme that will be used when installing plugins.
install = { colorscheme = { "habamax" } }, install = { colorscheme = { "habamax" } },
-- automatically check for plugin updates -- automatically check for plugin updates
checker = { checker = {
enabled = true, enabled = true,
notify=false, notify = false,
}, },
}) })

View File

@ -1,139 +1,139 @@
return { return {
braille = { "", "", "", "", "", "", "", "" }, braille = { "", "", "", "", "", "", "", "" },
triangles = { "", "", "", "" }, triangles = { "", "", "", "" },
dwarf_fortress = { dwarf_fortress = {
" ██████£££ ", " ██████£££ ",
"☺██████£££ ", "☺██████£££ ",
"☺██████£££ ", "☺██████£££ ",
"☺▓█████£££ ", "☺▓█████£££ ",
"☺▓█████£££ ", "☺▓█████£££ ",
"☺▒█████£££ ", "☺▒█████£££ ",
"☺▒█████£££ ", "☺▒█████£££ ",
"☺░█████£££ ", "☺░█████£££ ",
"☺░█████£££ ", "☺░█████£££ ",
"☺ █████£££ ", "☺ █████£££ ",
" ☺█████£££ ", " ☺█████£££ ",
" ☺█████£££ ", " ☺█████£££ ",
" ☺▓████£££ ", " ☺▓████£££ ",
" ☺▓████£££ ", " ☺▓████£££ ",
" ☺▒████£££ ", " ☺▒████£££ ",
" ☺▒████£££ ", " ☺▒████£££ ",
" ☺░████£££ ", " ☺░████£££ ",
" ☺░████£££ ", " ☺░████£££ ",
" ☺ ████£££ ", " ☺ ████£££ ",
" ☺████£££ ", " ☺████£££ ",
" ☺████£££ ", " ☺████£££ ",
" ☺▓███£££ ", " ☺▓███£££ ",
" ☺▓███£££ ", " ☺▓███£££ ",
" ☺▒███£££ ", " ☺▒███£££ ",
" ☺▒███£££ ", " ☺▒███£££ ",
" ☺░███£££ ", " ☺░███£££ ",
" ☺░███£££ ", " ☺░███£££ ",
" ☺ ███£££ ", " ☺ ███£££ ",
" ☺███£££ ", " ☺███£££ ",
" ☺███£££ ", " ☺███£££ ",
" ☺▓██£££ ", " ☺▓██£££ ",
" ☺▓██£££ ", " ☺▓██£££ ",
" ☺▒██£££ ", " ☺▒██£££ ",
" ☺▒██£££ ", " ☺▒██£££ ",
" ☺░██£££ ", " ☺░██£££ ",
" ☺░██£££ ", " ☺░██£££ ",
" ☺ ██£££ ", " ☺ ██£££ ",
" ☺██£££ ", " ☺██£££ ",
" ☺██£££ ", " ☺██£££ ",
" ☺▓█£££ ", " ☺▓█£££ ",
" ☺▓█£££ ", " ☺▓█£££ ",
" ☺▒█£££ ", " ☺▒█£££ ",
" ☺▒█£££ ", " ☺▒█£££ ",
" ☺░█£££ ", " ☺░█£££ ",
" ☺░█£££ ", " ☺░█£££ ",
" ☺ █£££ ", " ☺ █£££ ",
" ☺█£££ ", " ☺█£££ ",
" ☺█£££ ", " ☺█£££ ",
" ☺▓£££ ", " ☺▓£££ ",
" ☺▓£££ ", " ☺▓£££ ",
" ☺▒£££ ", " ☺▒£££ ",
" ☺▒£££ ", " ☺▒£££ ",
" ☺░£££ ", " ☺░£££ ",
" ☺░£££ ", " ☺░£££ ",
" ☺ £££ ", " ☺ £££ ",
" ☺£££ ", " ☺£££ ",
" ☺£££ ", " ☺£££ ",
" ☺▓££ ", " ☺▓££ ",
" ☺▓££ ", " ☺▓££ ",
" ☺▒££ ", " ☺▒££ ",
" ☺▒££ ", " ☺▒££ ",
" ☺░££ ", " ☺░££ ",
" ☺░££ ", " ☺░££ ",
" ☺ ££ ", " ☺ ££ ",
" ☺££ ", " ☺££ ",
" ☺££ ", " ☺££ ",
" ☺▓£ ", " ☺▓£ ",
" ☺▓£ ", " ☺▓£ ",
" ☺▒£ ", " ☺▒£ ",
" ☺▒£ ", " ☺▒£ ",
" ☺░£ ", " ☺░£ ",
" ☺░£ ", " ☺░£ ",
" ☺ £ ", " ☺ £ ",
" ☺£ ", " ☺£ ",
" ☺£ ", " ☺£ ",
" ☺▓ ", " ☺▓ ",
" ☺▓ ", " ☺▓ ",
" ☺▒ ", " ☺▒ ",
" ☺▒ ", " ☺▒ ",
" ☺░ ", " ☺░ ",
" ☺░ ", " ☺░ ",
"", "",
" ☺ &", " ☺ &",
" ☺ ☼&", " ☺ ☼&",
" ☺ ☼ &", " ☺ ☼ &",
" ☺☼ &", " ☺☼ &",
" ☺☼ & ", " ☺☼ & ",
" ‼ & ", " ‼ & ",
" ☺ & ", " ☺ & ",
" ‼ & ", " ‼ & ",
" ☺ & ", " ☺ & ",
" ‼ & ", " ‼ & ",
" ☺ & ", " ☺ & ",
"‼ & ", "‼ & ",
" & ", " & ",
" & ", " & ",
" & ░ ", " & ░ ",
" & ▒ ", " & ▒ ",
" & ▓ ", " & ▓ ",
" & £ ", " & £ ",
" & ░£ ", " & ░£ ",
" & ▒£ ", " & ▒£ ",
" & ▓£ ", " & ▓£ ",
" & ££ ", " & ££ ",
" & ░££ ", " & ░££ ",
" & ▒££ ", " & ▒££ ",
"& ▓££ ", "& ▓££ ",
"& £££ ", "& £££ ",
" ░£££ ", " ░£££ ",
" ▒£££ ", " ▒£££ ",
" ▓£££ ", " ▓£££ ",
" █£££ ", " █£££ ",
" ░█£££ ", " ░█£££ ",
" ▒█£££ ", " ▒█£££ ",
" ▓█£££ ", " ▓█£££ ",
" ██£££ ", " ██£££ ",
" ░██£££ ", " ░██£££ ",
" ▒██£££ ", " ▒██£££ ",
" ▓██£££ ", " ▓██£££ ",
" ███£££ ", " ███£££ ",
" ░███£££ ", " ░███£££ ",
" ▒███£££ ", " ▒███£££ ",
" ▓███£££ ", " ▓███£££ ",
" ████£££ ", " ████£££ ",
" ░████£££ ", " ░████£££ ",
" ▒████£££ ", " ▒████£££ ",
" ▓████£££ ", " ▓████£££ ",
" █████£££ ", " █████£££ ",
" ░█████£££ ", " ░█████£££ ",
" ▒█████£££ ", " ▒█████£££ ",
" ▓█████£££ ", " ▓█████£££ ",
" ██████£££ ", " ██████£££ ",
" ██████£££ ", " ██████£££ ",
}, },
} }

View File

@ -1,58 +1,58 @@
require('lsp-progress').setup({ require('lsp-progress').setup({
spinner = require('spinners').dwarf_fortress, spinner = require('spinners').dwarf_fortress,
spin_update_time = 200, spin_update_time = 200,
client_format = function(client_name, spinner, series_messages) client_format = function(client_name, spinner, series_messages)
return #series_messages > 0 return #series_messages > 0
and ( and (
table.concat(series_messages, ", ") table.concat(series_messages, ", ")
.. " " .. spinner .. " " .. spinner
.. " [" .. client_name .. "]" .. " [" .. client_name .. "]"
) )
or nil or nil
end, end,
}) })
require('lualine').setup { require('lualine').setup {
options = { options = {
icons_enabled = true, icons_enabled = true,
theme = 'auto', theme = 'auto',
component_separators = { left = '', right = ''}, component_separators = { left = '', right = '' },
section_separators = { left = '', right = ''}, section_separators = { left = '', right = '' },
disabled_filetypes = { disabled_filetypes = {
statusline = {}, statusline = {},
winbar = {}, winbar = {},
}, },
ignore_focus = {}, ignore_focus = {},
always_divide_middle = true, always_divide_middle = true,
globalstatus = false, globalstatus = false,
refresh = { refresh = {
statusline = 200, statusline = 200,
tabline = 1000, tabline = 1000,
winbar = 1000, winbar = 1000,
} }
}, },
sections = { sections = {
lualine_a = {'mode'}, lualine_a = { 'mode' },
lualine_b = {'branch', 'diff', 'diagnostics'}, lualine_b = { 'branch', 'diff', 'diagnostics' },
lualine_c = {'filename'}, lualine_c = { 'filename' },
lualine_x = { lualine_x = {
function() function()
return require('lsp-progress').progress() return require('lsp-progress').progress()
end end
}, },
lualine_y = {'encoding', 'fileformat', 'filetype'}, lualine_y = { 'encoding', 'fileformat', 'filetype' },
lualine_z = {'location'} lualine_z = { 'location' }
}, },
inactive_sections = { inactive_sections = {
lualine_a = {}, lualine_a = {},
lualine_b = {}, lualine_b = {},
lualine_c = {'filename'}, lualine_c = { 'filename' },
lualine_x = {'location'}, lualine_x = { 'location' },
lualine_y = {}, lualine_y = {},
lualine_z = {} lualine_z = {}
}, },
tabline = {}, tabline = {},
winbar = {}, winbar = {},
inactive_winbar = {}, inactive_winbar = {},
extensions = {} extensions = {}
} }