This commit is contained in:
Christoph J. Scherr 2024-02-16 18:03:36 +01:00
commit aefbe0981e
Signed by: PlexSheep
GPG Key ID: 7CDD0B14851A08EF
7 changed files with 133 additions and 28 deletions

View File

@ -6,7 +6,7 @@ local highlights = require "custom.highlights"
M.ui = {
theme = "oceanic-next",
theme_toggle = { "kanagawa", "oceanic-next" },
theme_toggle = { "oceanic-next", "oceanic-light" },
hl_override = highlights.override,
hl_add = highlights.add,

View File

@ -10,7 +10,7 @@ local servers = {
"tsserver",
"clangd",
"pyright",
"rust_analyzer", -- rustaceanvim wants to do that, but the builtin thing has better integration!
-- "rust_analyzer", -- rustaceanvim wants to do that, but the builtin thing has better integration!
"bashls",
"cmake",
}
@ -21,3 +21,28 @@ for _, lsp in ipairs(servers) do
capabilities = capabilities,
}
end
lspconfig.rust_analyzer.setup {
on_attach = on_attach,
settings = {
["rust-analyzer"] = {
check = {
command = "clippy",
},
imports = {
granularity = {
group = "module",
},
prefix = "self",
},
cargo = {
buildScripts = {
enable = true,
},
},
procMacro = {
enable = true,
},
},
},
}

View File

@ -9,14 +9,14 @@ M.override = {
Comment = {
italic = false,
},
NvDashAscii = {
fg = "#b33366",
bg = "#1a1a1a",
},
NvDashButtons = {
fg = "White",
bg = "#241e1e",
},
-- NvDashAscii = {
-- fg = "#b33366",
-- bg = "#1a1a1a",
-- },
-- NvDashButtons = {
-- fg = "White",
-- bg = "#241e1e",
-- },
}
---@type HLTable

View File

@ -70,15 +70,16 @@ opt.foldlevel = 10 -- start with all folds open
vim.o.guifont = "FiraCode Nerd Font:h22"
opt.termguicolors = true
opt.shortmess = "xsTOInfFitloCaAs"
opt.showmode = true -- Show mode in cmd window
opt.scrolloff = 2 -- Keep at least n lines above/below
opt.sidescrolloff = 0 -- Keep at least n lines left/right
opt.numberwidth = 2 -- Minimum number of columns to use for the line number
opt.number = true -- Show line numbers
opt.ruler = true -- Default status ruler
opt.list = true -- Show hidden characters
opt.showtabline = 1 -- Don't change this, goes back to a vanilla vim default
opt.laststatus = 3 -- Always show laststatus
opt.showmode = true -- Show mode in cmd window
opt.scrolloff = 2 -- Keep at least n lines above/below
opt.sidescrolloff = 0 -- Keep at least n lines left/right
opt.numberwidth = 2 -- Minimum number of columns to use for the line number
opt.number = true -- Show line numbers
opt.relativenumber = true -- Show relative line numbers
opt.ruler = true -- Default status ruler
opt.list = true -- Show hidden characters
opt.showtabline = 1 -- Don't change this, goes back to a vanilla vim default
opt.laststatus = 3 -- Always show laststatus
if vim.g.started_by_firenvim == true then
opt.showtabline = 1 -- Don't show tabline in firenvim, unless multitab

View File

@ -410,7 +410,8 @@ M.edit = {
-- format with conform
["<leader>ff"] = {
function()
vim.lsp.buf.format()
-- vim.lsp.buf.format()
require("conform").format()
end,
"format buffer",
},

View File

@ -102,7 +102,12 @@ local plugins = {
["<leader>f"] = { name = "+formatting" },
},
},
{ "echasnovski/mini.trailspace", lazy = false, event = { "BufReadPost", "BufNewFile" }, opts = {} },
{
"echasnovski/mini.trailspace",
lazy = false,
event = { "BufReadPost", "BufNewFile" },
opts = {},
},
{
"itchyny/vim-cursorword",
event = "FileType",
@ -515,11 +520,11 @@ local plugins = {
{
"kevinhwang91/nvim-ufo",
event = { "BufReadPost", "BufNewFile" },
-- stylua: ignore
keys = {
{ 'zR', function() require('ufo').openAllFolds() end },
{ 'zM', function() require('ufo').closeAllFolds() end },
},
-- stylua: ignore
keys = {
{ 'zR', function() require('ufo').openAllFolds() end },
{ 'zM', function() require('ufo').closeAllFolds() end },
},
dependencies = {
"kevinhwang91/promise-async",
"nvim-treesitter/nvim-treesitter",
@ -628,7 +633,7 @@ local plugins = {
end,
})
-- change how the highlighting looks
vim.cmd "hi LspInlayHint guibg=bg guifg=#804d66"
vim.cmd "hi LspInlayHint guibg=(bg*0.8) guifg=#6699b3"
end,
},
{ "kosayoda/nvim-lightbulb", event = { "BufReadPre", "BufNewFile" } },
@ -765,6 +770,9 @@ local plugins = {
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
args = function()
return require("custom.utils").tokenize_args(vim.fn.input "args: ")
end,
cwd = "${workspaceFolder}",
-- FIXME: perhaps we can put the stdio somewhere more practical
stopOnEntry = false,
@ -806,8 +814,11 @@ local plugins = {
config = function()
local dap = require "dap"
vim.g.rustaceanvim = {
enable_clippy = true,
-- Plugin configuration
tools = {},
tools = {
enable_clippy = true,
},
-- LSP configuration
server = {
auto_attach = false,

67
lua/custom/utils.lua Normal file
View File

@ -0,0 +1,67 @@
local M = {}
-- this function will split a string into a table of tokens, like it would
-- be passed into the `argv` of a program that was executed from the commandline
--
-- @param string raw string of cli args that should be split
-- @return table tokens args as a table
M.tokenize_args = function(raw)
-- NOTE: string.gmatch is does not use regex, but a smaller pattern matcher!
-- A complete regex parser would be larger than lua itself. See
-- [Programming in Lua 20.2](https://www.lua.org/pil/20.2.html).
--
-- Notable differences:
-- '-' is ungreedy wildcard
-- '*?' does not work
-- '|' is not or
--
-- This means we're better of implementing the lexer with an algorithm.
local t = {}
local current = ""
local in_str = false
local str_seek
for c in string.gmatch(raw, ".") do -- iterate through all chars
if c == ' ' and not in_str then
if string.len(current) > 0 then
table.insert(t, current)
current = ""
end
elseif c == '"' and not in_str then
in_str = true
str_seek = '"'
elseif c == "'" and not in_str then
in_str = true
str_seek = "'"
elseif c == str_seek and in_str then
in_str = false
table.insert(t, current)
current = ""
else
current = current .. c
end
end
if string.len(current) > 0 then
table.insert(t, current)
end
return t
end
--- dumps a variable into a string, so it can be printed. This is meant for
--- debug prints
--- @param any t any variable
--- @return string t_dumped t dumped to string
M.dump = function(t)
if type(t) == 'table' then
local s = '{ '
for k, v in pairs(t) do
if type(k) ~= 'number' then k = '"' .. k .. '"' end
if k ~= 1 then
s = s .. ', '
end
s = s .. '[' .. k .. '] = \'' .. M.dump(v) .. '\''
end
return s .. ' }'
else
return tostring(t)
end
end
return M