diff --git a/dotfiles/.config/alacritty/alacritty.toml b/dotfiles/.config/alacritty/alacritty.toml index 2f95351..acf2d4c 100644 --- a/dotfiles/.config/alacritty/alacritty.toml +++ b/dotfiles/.config/alacritty/alacritty.toml @@ -1,9 +1,9 @@ -live_config_reload = true -working_directory = "None" - +[general] import = [ "~/.config/alacritty/light.toml" ] +live_config_reload = true +working_directory = "None" [cursor] thickness = 0.2 @@ -414,7 +414,7 @@ history = 100000 save_to_clipboard = true semantic_escape_chars = ",│`|:\"' ()[]{}<>\t" -[shell] +[terminal.shell] program = "/bin/bash" [window] diff --git a/dotfiles/.config/mako/config b/dotfiles/.config/mako/config index a32fc19..a19fc01 100644 --- a/dotfiles/.config/mako/config +++ b/dotfiles/.config/mako/config @@ -1,6 +1,6 @@ sort=-time -default-timeout=0 -ignore-timeout=0 +default-timeout=5000 +ignore-timeout=1 height=200 width=400 @@ -17,16 +17,14 @@ border-radius=10 background-color=#eff1f5E0 text-color=#4c4f69 -border-color=#40a02b progress-color=over #ccd0da [urgency=low] border-color=#c1ca8c -[urgency=high] -border-color=#fe040b -background-color=#ffe1e5 +[urgency=normal] +border-color=#a1bacc [urgency=critical] border-color=#fe040b -background-color=#ffe1e5 +default-timeout=0 diff --git a/dotfiles/.config/nvim/after/lsp/ty.lua b/dotfiles/.config/nvim/after/lsp/ty.lua new file mode 100644 index 0000000..4f1df79 --- /dev/null +++ b/dotfiles/.config/nvim/after/lsp/ty.lua @@ -0,0 +1,6 @@ +-- ~/.config/nvim/after/lsp/ty.lua +return { + cmd = { "ty", "server" }, + filetypes = { "python" }, + root_dir = vim.fs.root(0, { ".git/", "pyproject.toml" }), +} diff --git a/dotfiles/.config/nvim/lua/keymappings.lua b/dotfiles/.config/nvim/lua/keymappings.lua index 58f4ca9..ab520fd 100644 --- a/dotfiles/.config/nvim/lua/keymappings.lua +++ b/dotfiles/.config/nvim/lua/keymappings.lua @@ -19,6 +19,10 @@ vim.keymap.set("n", "aa", require("actions-preview").code_actions) -- Outline!! vim.keymap.set("n", "o", "Outline") - -- Close all buffers vim.keymap.set("n", '', "bufdo bd") + +vim.keymap.set("n", "", "lua vim.lsp.buf.rename()()") +vim.keymap.set("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))") +vim.keymap.set("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") +vim.keymap.set("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") diff --git a/dotfiles/.config/nvim/lua/lsp.lua b/dotfiles/.config/nvim/lua/lsp.lua index 5f337ea..40b14dc 100644 --- a/dotfiles/.config/nvim/lua/lsp.lua +++ b/dotfiles/.config/nvim/lua/lsp.lua @@ -1,15 +1,6 @@ local autoformat_files = '*.py,*.rs,*.tf' local common_on_attach = function(client, bufnr) - -- Mappings. - vim.keymap.set("n", "K", "lua vim.lsp.buf.hover()") - vim.keymap.set("n", "", "lua vim.lsp.buf.signature_help()") - vim.keymap.set("n", "", "lua vim.lsp.buf.type_definition()") - vim.keymap.set("n", "", "lua vim.lsp.buf.rename()()") - vim.keymap.set("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))") - vim.keymap.set("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") - vim.keymap.set("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") - -- Autoformat on save. if client.supports_method("textDocument/formatting") then vim.api.nvim_create_autocmd("BufWritePre", { @@ -27,64 +18,6 @@ local common_on_attach = function(client, bufnr) end end -local nvim_lsp = require('lspconfig') -local capabilities = vim.lsp.protocol.make_client_capabilities() - --- LSPs -local servers = { - "clangd", - "gleam", - "lua_ls", - "ocamllsp", - "pyright", - "rnix", - "terraformls", - "vimls", -} -for _, lsp in ipairs(servers) do - nvim_lsp[lsp].setup { capabilities = capabilities, on_attach = common_on_attach } -end - -nvim_lsp.rust_analyzer.setup({ - on_attach = common_on_attach, - capabilities = capabilities, - settings = { - ["rust-analyzer"] = { - imports = { - granularity = { - group = "module", - }, - prefix = "self", - }, - cargo = { - buildScripts = { - enable = true, - }, - }, - procMacro = { - enable = true - }, - checkOnSave = { - command = "clippy", - }, - } - } -}) - -nvim_lsp.ruff.setup({ - on_attach = function (client) - common_on_attach(client) - client.server_capabilities.renameProvider = false - client.server_capabilities.hoverProvider = false - end, - init_options = { - settings = { - -- Any extra CLI arguments for `ruff` go here. - args = {} - } - }, -}) - -- LSP diagnostics. vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { @@ -93,3 +26,61 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] = signs = true, update_in_insert = false }) + +-- Setup rust outside of lspconfig. +vim.g.rustaceanvim = function() + return { + -- Plugin configuration. + tools = { + }, + -- LSP configuration. + server = { + on_attach = function(client, bufnr) + common_on_attach(client, bufnr) + end, + default_settings = { + -- rust-analyzer language server configuration + ['rust-analyzer'] = { + imports = { + granularity = { + group = "module", + }, + prefix = "self", + }, + cargo = { + buildScripts = { + enable = true, + }, + }, + procMacro = { + enable = true + }, + checkOnSave = true, + }, + }, + -- DAP configuration. + dap = { + }, + } + } +end + +local capabilities = vim.lsp.protocol.make_client_capabilities() + +vim.lsp.enable('ty') + +-- LSPs +local servers = { + "clangd", + "lua_ls", + "ocamllsp", + "rnix", + "terraformls", + "vimls", +} +for _, lsp in ipairs(servers) do + vim.lsp.config(lsp, { + capabilities = capabilities, + on_attach = common_on_attach, + }) +end diff --git a/dotfiles/.config/nvim/lua/plugins/catppuccin.lua b/dotfiles/.config/nvim/lua/plugins/catppuccin.lua index e29ea46..3cbb45c 100644 --- a/dotfiles/.config/nvim/lua/plugins/catppuccin.lua +++ b/dotfiles/.config/nvim/lua/plugins/catppuccin.lua @@ -16,7 +16,7 @@ require("catppuccin").setup({ TelescopeNormal = { bg = "#fafafa" }, TelescopePromptNormal = { bg = colors.surface1 }, TelescopePromptBorder = { bg = colors.surface1, fg = colors.surface1 }, - CursorLine = { bg = colors.text }, + CursorLine = { bg = colors.surface2 }, NvimTreeWinSeparator = { fg = colors.text }, NvimTreeGitNew = { fg = colors.green }, NvimTreeGitDirty = { fg = colors.yellow }, @@ -100,6 +100,9 @@ require("catppuccin").setup({ DiagnosticUnnecessary = { link = "" }, + Pmenu = { fg = colors.text }, + PmenuSel = { bg = colors.overlay0 }, + --["@conceal.checked"] = { fg = colors.teal }, --["@none"] = { link = "Normal" }, --["@field"] = { fg = colors.blue }, diff --git a/dotfiles/.config/nvim/lua/plugins/dap.lua b/dotfiles/.config/nvim/lua/plugins/dap.lua new file mode 100644 index 0000000..cf4f022 --- /dev/null +++ b/dotfiles/.config/nvim/lua/plugins/dap.lua @@ -0,0 +1,120 @@ +local dap, dapui = require('dap'), require('dapui') + +-- Open dapui once dap starts. +dapui.setup() +dap.listeners.before.attach.dapui_config = function() + dapui.open() +end +dap.listeners.before.launch.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 + +-- Keybindings used in probably all editors/IDEs. +vim.keymap.set('n', '', dap.continue) +vim.keymap.set('n', '', dap.step_over) +vim.keymap.set('n', '', dap.step_into) +vim.keymap.set('n', '', dap.step_out) +-- Breakpoints. +vim.keymap.set('n', 'b', dap.toggle_breakpoint) +vim.keymap.set('n', 'B', dap.set_breakpoint) +vim.keymap.set('n', 'lp', function() dap.set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) end) +-- Repl, run and dap-ui bindings. +vim.keymap.set('n', 'dr', dap.repl.open) +vim.keymap.set('n', 'dl', dap.run_last) +vim.keymap.set({'n', 'v'}, 'dh', function() require('dap.ui.widgets').hover() end) +vim.keymap.set({'n', 'v'}, 'dp', function() require('dap.ui.widgets').preview() end) +vim.keymap.set('n', 'df', function() local widgets = require('dap.ui.widgets') widgets.centered_float(widgets.frames) end) +vim.keymap.set('n', 'ds', function() local widgets = require('dap.ui.widgets') widgets.centered_float(widgets.scopes) end) + +vim.fn.sign_define('DapBreakpoint', {text='󰬪', texthl='', linehl='', numhl=''}) + +-- Set up lldb (LLVM debugger) +-- Install archlinux: sudo pacman -S lldb +-- Install ubuntu: sudo apt +dap.adapters.lldb = { + type = 'server', + port = "${port}", + executable = { + command = '/usr/bin/lldb-dap', + args = { "--port", "${port}" }, + }, +} + +-- Custom debuggable build runs (on top of rust-analyzer debuggables). +local ExecTypes = { + TEST = "cargo build --tests -q --message-format=json", + BIN = "cargo build -q --message-format=json" +} +local function runBuild(type) + local lines = vim.fn.systemlist(type) + local output = table.concat(lines, "\n") + local filename = output:match('^.*"executable":"(.*)",.*\n.*,"success":true}$') + + if filename == nil then + return error("failed to build cargo project") + end + + return filename +end +-- Custom debuggable configurations. +dap.configurations.rust = { + { + name = "Debug Test", + type = "lldb", + request = "launch", + program = function () + return runBuild(ExecTypes.TEST) + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + showDisassembly = "never" + }, + { + name = "Debug Bin", + type = "lldb", + request = "launch", + program = function () + return runBuild(ExecTypes.BIN) + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + showDisassembly = "never" + } +} + +-- Set up debugpy via uv +dap.adapters.python = { + type = 'server', + port = "${port}", + host = "127.0.0.1", + executable = { + command = "uvx", + args = { + "debugpy", + "--listen", + "127.0.0.1:${port}", + "--wait-for-client", + }, + }, + options = { + source_filetype = 'python', + }, +} + +dap.configurations.python = { + { + type = 'python'; + request = 'launch'; + name = "Launch file"; + program = "${file}"; + pythonPath = function() + return "${workspaceFolder}/.venv/bin/python" + end; + }, +} diff --git a/dotfiles/.config/nvim/lua/plugins/init.lua b/dotfiles/.config/nvim/lua/plugins/init.lua index 61e0a61..cb6ca9d 100644 --- a/dotfiles/.config/nvim/lua/plugins/init.lua +++ b/dotfiles/.config/nvim/lua/plugins/init.lua @@ -3,6 +3,7 @@ require('plugins.packer_setup') require('packer').startup(function() -- Packer can manage itself as an optional plugin use { 'wbthomason/packer.nvim', opt = true } + use { 'glepnir/nerdicons.nvim', cmd = 'NerdIcons', config = function() require('nerdicons').setup({}) end } -- Fuzzy finder use { @@ -38,14 +39,29 @@ require('packer').startup(function() -- LSP and related use { 'neovim/nvim-lspconfig' } use { 'aznhe21/actions-preview.nvim' } - use { 'folke/trouble.nvim' } -- lsp diagnostics + use { 'folke/trouble.nvim' } -- diagnostics - -- Plugins to extend builtin language support + -- Plugins to extend builtin lsp use { 'cespare/vim-toml' } use { 'gleam-lang/gleam.vim' } - use { 'rust-lang/rust.vim' } use { 'folke/neodev.nvim' } use { 'hashivim/vim-terraform' } + use { + 'mrcjkb/rustaceanvim', + requires = { + 'mfussenegger/nvim-dap' + } + } + + -- Debugging + use { 'mfussenegger/nvim-dap' } + use { + "rcarriga/nvim-dap-ui", + requires = { + "mfussenegger/nvim-dap", + "nvim-neotest/nvim-nio", + } + } -- Git use { @@ -70,6 +86,7 @@ end) require('plugins.catppuccin') require('plugins.cmp') +require('plugins.dap') require('plugins.gitsigns') require('plugins.luasnip_config') require('plugins.neogit') diff --git a/dotfiles/.config/nvim/lua/plugins/neogit.lua b/dotfiles/.config/nvim/lua/plugins/neogit.lua index 771a0e6..57b7d83 100644 --- a/dotfiles/.config/nvim/lua/plugins/neogit.lua +++ b/dotfiles/.config/nvim/lua/plugins/neogit.lua @@ -24,9 +24,11 @@ neogit.setup { graph_style = "ascii", -- Used to generate URL's for branch popup action "pull request". git_services = { - ["github.com"] = "https://github.com/${owner}/${repository}/compare/${branch_name}?expand=1", - ["bitbucket.org"] = "https://bitbucket.org/${owner}/${repository}/pull-requests/new?source=${branch_name}&t=1", - ["gitlab.com"] = "https://gitlab.com/${owner}/${repository}/merge_requests/new?merge_request[source_branch]=${branch_name}", + ["github.com"] = { + pull_request = "https://github.com/${owner}/${repository}/compare/${branch_name}?expand=1", + commit = "https://github.com/${owner}/${repository}/commit/${oid}", + tree = "https://${host}/${owner}/${repository}/tree/${branch_name}", + }, }, -- Allows a different telescope sorter. Defaults to 'fuzzy_with_index_bias'. The example below will use the native fzf -- sorter instead. By default, this function returns `nil`. diff --git a/dotfiles/.config/nvim/lua/plugins/oil.lua b/dotfiles/.config/nvim/lua/plugins/oil.lua index 884e296..16e9fbb 100644 --- a/dotfiles/.config/nvim/lua/plugins/oil.lua +++ b/dotfiles/.config/nvim/lua/plugins/oil.lua @@ -53,7 +53,7 @@ require('oil').setup({ -- Skip the confirmation popup for simple operations skip_confirm_for_simple_edits = false, -- Change this to customize the command used when deleting to trash - trash_command = "trash-put", + -- trash_command = "trash-put", -- Selecting a new/moved/renamed file or directory will prompt you to save changes first prompt_save_on_select_new_entry = true, -- Keymaps in oil buffer. Can be any value that `vim.keymap.set` accepts OR a table of keymap diff --git a/dotfiles/.config/nvim/lua/plugins/telescope.lua b/dotfiles/.config/nvim/lua/plugins/telescope.lua index 08388d6..eb347c0 100644 --- a/dotfiles/.config/nvim/lua/plugins/telescope.lua +++ b/dotfiles/.config/nvim/lua/plugins/telescope.lua @@ -45,6 +45,8 @@ telescope.setup { file_ignore_patterns = { '.git/', '.venv/', + '.pytest_cache/', + 'target/', }, }, pickers = { diff --git a/dotfiles/.config/sway/config.d/90-bindings.conf b/dotfiles/.config/sway/config.d/90-bindings.conf index 2f16926..a38c706 100644 --- a/dotfiles/.config/sway/config.d/90-bindings.conf +++ b/dotfiles/.config/sway/config.d/90-bindings.conf @@ -122,9 +122,9 @@ bindsym $mod+z exec swaylock -c 000000 # Take full screen screenshot with PrtScr -bindsym Print exec grim -t png "~/screenshot-$(date +%Y-%m-%d-%H%M%S).png" +bindsym Print exec grim -t png ~/screenshot-$(date +%Y-%m-%d-%H%M%S).png # Take area screenshot with Shift+PrtScr -bindsym Shift+Print exec grim -g "$(slurp)" "~/screenshot-$(date +%Y-%m-%d-%H%M%S).png" +bindsym Shift+Print exec grim -g "$(slurp)" ~/screenshot-$(date +%Y-%m-%d-%H%M%S).png # # Resizing containers: