diff --git a/.config/nvim/lua/user/cybu.lua b/.config/nvim/lua/user/cybu.lua new file mode 100644 index 0000000..02a8dea --- /dev/null +++ b/.config/nvim/lua/user/cybu.lua @@ -0,0 +1,30 @@ +local ok, cybu = pcall(require, "cybu") +if not ok then + return +end +cybu.setup { + position = { + relative_to = "win", -- win, editor, cursor + anchor = "topright", -- topleft, topcenter, topright, + -- centerleft, center, centerright, + -- bottomleft, bottomcenter, bottomright + -- vertical_offset = 10, -- vertical offset from anchor in lines + -- horizontal_offset = 0, -- vertical offset from anchor in columns + -- max_win_height = 5, -- height of cybu window in lines + -- max_win_width = 0.5, -- integer for absolute in columns + -- float for relative to win/editor width + }, + display_time = 1750, -- time the cybu window is displayed + style = { + path = "relative", -- absolute, relative, tail (filename only) + border = "rounded", -- single, double, rounded, none + separator = " ", -- string used as separator + prefix = "…", -- string used as prefix for truncated paths + padding = 1, -- left & right padding in number of spaces + hide_buffer_id = true, + devicons = { + enabled = true, -- enable or disable web dev icons + colored = true, -- enable color for web dev icons + }, + }, +} diff --git a/.config/nvim/lua/user/dap.lua b/.config/nvim/lua/user/dap.lua new file mode 100644 index 0000000..e86baca --- /dev/null +++ b/.config/nvim/lua/user/dap.lua @@ -0,0 +1,133 @@ +local dap_status_ok, dap = pcall(require, "dap") +if not dap_status_ok then + print("error requiring dap") + return +end + +local dap_ui_status_ok, dapui = pcall(require, "dapui") +if not dap_ui_status_ok then + print("error requiring dapui") + return +end + +-- dapui.setup() +dapui.setup({ + icons = { expanded = "▾", collapsed = "▸" }, + mappings = { + -- Use a table to apply multiple mappings + expand = { "", "<2-LeftMouse>" }, + open = "o", + remove = "d", + edit = "e", + repl = "r", + toggle = "t", + }, + -- Expand lines larger than the window + -- Requires >= 0.7 + expand_lines = vim.fn.has("nvim-0.7"), + -- Layouts define sections of the screen to place windows. + -- The position can be "left", "right", "top" or "bottom". + -- The size specifies the height/width depending on position. It can be an Int + -- or a Float. Integer specifies height/width directly (i.e. 20 lines/columns) while + -- Float value specifies percentage (i.e. 0.3 - 30% of available lines/columns) + -- Elements are the elements shown in the layout (in order). + -- Layouts are opened in order so that earlier layouts take priority in window sizing. + layouts = { + { + elements = { + -- Elements can be strings or table with id and size keys. + { id = "scopes", size = 0.25 }, + "breakpoints", + -- "stacks", + -- "watches", + }, + size = 40, -- 40 columns + position = "right", + }, + { + elements = { + "repl", + "console", + }, + size = 0.25, -- 25% of total lines + position = "bottom", + }, + }, + floating = { + max_height = nil, -- These can be integers or a float between 0 and 1. + max_width = nil, -- Floats will be treated as percentage of your screen. + border = "single", -- Border style. Can be "single", "double" or "rounded" + mappings = { + close = { "q", "" }, + }, + }, + windows = { indent = 1 }, + render = { + max_type_length = nil, -- Can be integer or nil. + }, +}) + +local icons = require("user.icons") + +vim.fn.sign_define("DapBreakpoint", { text = icons.ui.Bug, texthl = "DiagnosticSignError", linehl = "", numhl = "" }) + +dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open({}) +end +dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close({}) +end +dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close({}) +end + +-- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#Dotnet +dap.adapters.coreclr = { + type = 'executable', + command = 'netcoredbg', + args = {'--interpreter=vscode'} +} + +dap.configurations.cs = { + { + type = "coreclr", + name = "launch - netcoredbg", + request = "launch", + program = function() + return vim.fn.input('Path to dll', vim.fn.getcwd() .. '/bin/Debug/', 'file') + end, + }, +} + +-- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#Javascript-chrome +dap.adapters.chrome = { + type = "executable", + command = "node", + args = {"/home/solomon/repos/vscode-chrome-debug/out/src/chromeDebug.js"} +} + +dap.configurations.javascript = { -- change this to javascriptreact if needed + { + type = "chrome", + request = "attach", + program = "${file}", + cwd = vim.fn.getcwd(), + sourceMaps = true, + protocol = "inspector", + port = 9222, + webRoot = "${workspaceFolder}" + } +} + +dap.configurations.typescript = { -- change to typescriptreact if needed + { + type = "chrome", + request = "attach", + program = "${file}", + cwd = vim.fn.getcwd(), + sourceMaps = true, + protocol = "inspector", + port = 9222, + webRoot = "${workspaceFolder}" + } +} diff --git a/.config/nvim/lua/user/dial.lua b/.config/nvim/lua/user/dial.lua new file mode 100644 index 0000000..a561734 --- /dev/null +++ b/.config/nvim/lua/user/dial.lua @@ -0,0 +1,67 @@ +local status_ok, dial_config = pcall(require, "dial.config") +if not status_ok then + return +end + +local y = "2024/05/29" + +local augend = require "dial.augend" +dial_config.augends:register_group { + default = { + augend.integer.alias.decimal, + augend.integer.alias.hex, + augend.date.alias["%Y/%m/%d"], + }, + typescript = { + augend.integer.alias.decimal, + augend.integer.alias.hex, + augend.constant.new { elements = { "let", "const" } }, + }, + visual = { + augend.integer.alias.decimal, + augend.integer.alias.hex, + augend.date.alias["%Y/%m/%d"], + augend.constant.alias.alpha, + augend.constant.alias.Alpha, + }, + mygroup = { + augend.constant.new { + elements = { "and", "or" }, + word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc. + cyclic = true, -- "or" is incremented into "and". + }, + augend.constant.new { + elements = { "True", "False" }, + word = true, + cyclic = true, + }, + augend.constant.new { + elements = { "public", "private" }, + word = true, + cyclic = true, + }, + augend.constant.new { + elements = { "&&", "||" }, + word = false, + cyclic = true, + }, + augend.date.alias["%d/%m/%Y"], -- date (02/19/2022, etc.) + augend.constant.alias.bool, -- boolean value (true <-> false) + augend.integer.alias.decimal, + augend.integer.alias.hex, + augend.semver.alias.semver + }, +} + +local map = require "dial.map" + +-- change augends in VISUAL mode +vim.api.nvim_set_keymap("n", "", map.inc_normal "mygroup", { noremap = true }) +vim.api.nvim_set_keymap("n", "", map.dec_normal "mygroup", { noremap = true }) +vim.api.nvim_set_keymap("v", "", map.inc_normal "visual", { noremap = true }) +vim.api.nvim_set_keymap("v", "", map.dec_normal "visual", { noremap = true }) + +vim.cmd [[ + " enable only for specific FileType + autocmd FileType typescript,javascript lua vim.api.nvim_buf_set_keymap(0, "n", "", require("dial.map").inc_normal("typescript"), {noremap = true}) +]] diff --git a/.config/nvim/lua/user/lsp/null-ls.lua b/.config/nvim/lua/user/lsp/null-ls.lua new file mode 100644 index 0000000..84de120 --- /dev/null +++ b/.config/nvim/lua/user/lsp/null-ls.lua @@ -0,0 +1,57 @@ +local null_ls_status_ok, null_ls = pcall(require, "null-ls") +if not null_ls_status_ok then + return +end + +-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting +local formatting = null_ls.builtins.formatting +-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics +local diagnostics = null_ls.builtins.diagnostics + +-- https://github.com/prettier-solidity/prettier-plugin-solidity +-- npm install --save-dev prettier prettier-plugin-solidity +null_ls.setup { + debug = false, + sources = { + formatting.prettier.with { + extra_filetypes = { "toml", "solidity" }, + extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" }, + }, + formatting.black.with { extra_args = { "--fast" } }, + formatting.stylua, + formatting.shfmt, + formatting.google_java_format, + -- diagnostics.flake8, + diagnostics.shellcheck, + }, +} + +local unwrap = { + method = null_ls.methods.DIAGNOSTICS, + filetypes = { "rust" }, + generator = { + fn = function(params) + local diagnostics = {} + -- sources have access to a params object + -- containing info about the current file and editor state + for i, line in ipairs(params.content) do + local col, end_col = line:find "unwrap()" + if col and end_col then + -- null-ls fills in undefined positions + -- and converts source diagnostics into the required format + table.insert(diagnostics, { + row = i, + col = col, + end_col = end_col, + source = "unwrap", + message = "hey " .. os.getenv("USER") .. ", don't forget to handle this" , + severity = 2, + }) + end + end + return diagnostics + end, + }, +} + +null_ls.register(unwrap) diff --git a/.config/nvim/lua/user/vimtex.lua b/.config/nvim/lua/user/vimtex.lua new file mode 100644 index 0000000..1f1e4db --- /dev/null +++ b/.config/nvim/lua/user/vimtex.lua @@ -0,0 +1,89 @@ +-- Disable imaps (using Ultisnips) +vim.g.vimtex_imaps_enabled = 0 +-- Do not open pdfviwer on compile +vim.g.vimtex_view_automatic = 0 +-- Disable conceal +vim.g.vimtex_syntax_conceal = { + accents = 0, + cites = 0, + fancy = 0, + greek = 0, + math_bounds = 0, + math_delimiters = 0, + math_fracs = 0, + math_super_sub = 0, + math_symbols = 0, + sections = 0, + styles = 0, +} +-- Disable quickfix auto open +vim.g.vimtex_quickfix_ignore_mode = 0 +-- PDF viewer settings +vim.g.vimtex_view_general_viewer = "SumatraPDF" +vim.g.vimtex_view_general_options = "-reuse-instance -forward-search @tex @line @pdf" +-- Do not auto open quickfix on compile erros +vim.g.vimtex_quickfix_mode = 0 +-- Latex warnings to ignore +vim.g.vimtex_quickfix_ignore_filters = { + "Command terminated with space", + "LaTeX Font Warning: Font shape", + "Package caption Warning: The option", + [[Underfull \\hbox (badness [0-9]*) in]], + "Package enumitem Warning: Negative labelwidth", + [[Overfull \\hbox ([0-9]*.[0-9]*pt too wide) in]], + [[Package caption Warning: Unused \\captionsetup]], + "Package typearea Warning: Bad type area settings!", + [[Package fancyhdr Warning: \\headheight is too small]], + [[Underfull \\hbox (badness [0-9]*) in paragraph at lines]], + "Package hyperref Warning: Token not allowed in a PDF string", + [[Overfull \\hbox ([0-9]*.[0-9]*pt too wide) in paragraph at lines]], +} +vim.g.vimtex_fold_enabled = 1 +vim.g.vimtex_fold_manual = 1 +vim.g.vimtex_fold_types = { + cmd_addplot = { + cmds = { "addplot[+3]?" }, + }, + cmd_multi = { + cmds = { + "%(re)?new%(command|environment)", + "providecommand", + "presetkeys", + "Declare%(Multi|Auto)?CiteCommand", + "Declare%(Index)?%(Field|List|Name)%(Format|Alias)", + }, + }, + cmd_single = { + cmds = { "hypersetup", "tikzset", "pgfplotstableread", "lstset" }, + }, + cmd_single_opt = { + cmds = { "usepackage", "includepdf" }, + }, + comments = { + enabled = 0, + }, + env_options = vim.empty_dict(), + envs = { + blacklist = {}, + whitelist = { "figure", "frame", "table", "example", "answer" }, + }, + items = { + enabled = 0, + }, + markers = vim.empty_dict(), + preamble = { + enabled = 0, + }, + sections = { + parse_levels = 0, + parts = { "appendix", "frontmatter", "mainmatter", "backmatter" }, + sections = { + "%(add)?part", + "%(chapter|addchap)", + "%(section|section\\*)", + "%(subsection|subsection\\*)", + "%(subsubsection|subsubsection\\*)", + "paragraph", + }, + }, +}