diff --git a/lua/custom/chadrc.lua b/lua/custom/chadrc.lua index 7e7dc46..8f1a86b 100644 --- a/lua/custom/chadrc.lua +++ b/lua/custom/chadrc.lua @@ -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, diff --git a/lua/custom/configs/lspconfig.lua b/lua/custom/configs/lspconfig.lua index 88b5536..8175149 100644 --- a/lua/custom/configs/lspconfig.lua +++ b/lua/custom/configs/lspconfig.lua @@ -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, + }, + }, + }, +} diff --git a/lua/custom/highlights.lua b/lua/custom/highlights.lua index 24d82d5..096b8b8 100644 --- a/lua/custom/highlights.lua +++ b/lua/custom/highlights.lua @@ -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 diff --git a/lua/custom/init.lua b/lua/custom/init.lua index 24586dc..2b1f16f 100644 --- a/lua/custom/init.lua +++ b/lua/custom/init.lua @@ -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 diff --git a/lua/custom/mappings.lua b/lua/custom/mappings.lua index 0dcfdc2..2c5d8f4 100644 --- a/lua/custom/mappings.lua +++ b/lua/custom/mappings.lua @@ -410,7 +410,8 @@ M.edit = { -- format with conform ["ff"] = { function() - vim.lsp.buf.format() + -- vim.lsp.buf.format() + require("conform").format() end, "format buffer", }, diff --git a/lua/custom/plugins.lua b/lua/custom/plugins.lua index 5c9d348..3fcf528 100644 --- a/lua/custom/plugins.lua +++ b/lua/custom/plugins.lua @@ -102,7 +102,12 @@ local plugins = { ["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, diff --git a/lua/custom/utils.lua b/lua/custom/utils.lua new file mode 100644 index 0000000..524c2d4 --- /dev/null +++ b/lua/custom/utils.lua @@ -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