diff --git a/.zshrc b/.zshrc index dd11ad0..3a8780f 100644 --- a/.zshrc +++ b/.zshrc @@ -37,3 +37,122 @@ alias gh='git push origin' alias gl='git pull origin' alias gm='git commit -m' + +# zoxide +## ============================================================================= +# +# Utility functions for zoxide. +# + +# pwd based on the value of _ZO_RESOLVE_SYMLINKS. +function __zoxide_pwd() { + \builtin pwd -L +} + +# cd + custom logic based on the value of _ZO_ECHO. +function __zoxide_cd() { + # shellcheck disable=SC2164 + \builtin cd -- "$@" >/dev/null +} + +# ============================================================================= +# +# Hook configuration for zoxide. +# + +# Hook to add new entries to the database. +function __zoxide_hook() { + # shellcheck disable=SC2312 + \command zoxide add -- "$(__zoxide_pwd)" +} + +# Initialize hook. +# shellcheck disable=SC2154 +if [[ ${precmd_functions[(Ie)__zoxide_hook]:-} -eq 0 ]] && [[ ${chpwd_functions[(Ie)__zoxide_hook]:-} -eq 0 ]]; then + chpwd_functions+=(__zoxide_hook) +fi + +# ============================================================================= +# +# When using zoxide with --no-cmd, alias these internal functions as desired. +# + +__zoxide_z_prefix='z#' + +# Jump to a directory using only keywords. +function __zoxide_z() { + # shellcheck disable=SC2199 + if [[ "$#" -eq 0 ]]; then + __zoxide_cd ~ + elif [[ "$#" -eq 1 ]] && { [[ -d "$1" ]] || [[ "$1" = '-' ]] || [[ "$1" =~ ^[-+][0-9]$ ]]; }; then + __zoxide_cd "$1" + elif [[ "$@[-1]" == "${__zoxide_z_prefix}"* ]]; then + # shellcheck disable=SC2124 + \builtin local result="${@[-1]}" + __zoxide_cd "${result:${#__zoxide_z_prefix}}" + else + \builtin local result + # shellcheck disable=SC2312 + result="$(\command zoxide query --exclude "$(__zoxide_pwd)" -- "$@")" && + __zoxide_cd "${result}" + fi +} + +# Jump to a directory using interactive search. +function __zoxide_zi() { + \builtin local result + result="$(\command zoxide query -i -- "$@")" && __zoxide_cd "${result}" +} + +# ============================================================================= +# +# Commands for zoxide. Disable these using --no-cmd. +# + +\builtin unalias z &>/dev/null || \builtin true +function z() { + __zoxide_z "$@" +} + +\builtin unalias zi &>/dev/null || \builtin true +function zi() { + __zoxide_zi "$@" +} + +if [[ -o zle ]]; then + function __zoxide_z_complete() { + # Only show completions when the cursor is at the end of the line. + # shellcheck disable=SC2154 + [[ "${#words[@]}" -eq "${CURRENT}" ]] || return + + if [[ "${#words[@]}" -eq 2 ]]; then + _files -/ + elif [[ "${words[-1]}" == '' ]]; then + \builtin local result + # shellcheck disable=SC2086,SC2312 + if result="$(\command zoxide query --exclude "$(__zoxide_pwd)" -i -- ${words[2,-1]})"; then + __zoxide_result="${result}" + else + __zoxide_result='' + fi + \builtin printf '\e[5n' + fi + } + + function __zoxide_z_complete_helper() { + \builtin local result="${__zoxide_z_prefix}${__zoxide_result}" + # shellcheck disable=SC2296 + [[ -n "${__zoxide_result}" ]] && LBUFFER="${LBUFFER}${(q-)result}" + \builtin zle reset-prompt + } + + \builtin zle -N __zoxide_z_complete_helper + \builtin bindkey "\e[0n" __zoxide_z_complete_helper + if [[ "${+functions[compdef]}" -ne 0 ]]; then + \compdef -d z + \compdef -d zi + \compdef __zoxide_z_complete z + fi +fi + +# ============================================================================= diff --git a/hypr_desktop/hyprland.conf b/hypr_desktop/hyprland.conf index e35990e..6a915e9 100644 --- a/hypr_desktop/hyprland.conf +++ b/hypr_desktop/hyprland.conf @@ -108,7 +108,7 @@ bind=SUPER,S,exec,grim -g "$(slurp)" - | wl-copy bind=SUPERSHIFTALT,S,exec,grim -g "$(slurp)" $HOME/gits/ost-3semester/Screenshots/$(date +'%Y-%m-%d:%I:%M:%S.png') bind=SUPERSHIFT,S,exec,grim -g "$(slurp)" - | swappy -f - bind=SUPER,F,exec,firefox -bind=SUPER,T,exec,alacritty +bind=SUPER,T,exec,kitty bind=SUPER,Q,killactive, bind=SUPER,M,exit, bind=SUPER,E,exec,nautilus --new-window diff --git a/kitty/kitty.conf b/kitty/kitty.conf new file mode 100644 index 0000000..09b03da --- /dev/null +++ b/kitty/kitty.conf @@ -0,0 +1,53 @@ +enable_audio_bell no +window_alert_on_bell no +background_opacity 0.7 +cursor_blink_interval 0 + +background #1d1f21 +foreground #c5c8c6 + +selection_background #b2ceee +selection_foreground #080808 + +selection_background #33467c +selection_foreground #c0caf5 +url_color #73daca +cursor #c0caf5 +cursor_text_color #1a1b26 + +# Tabs +active_tab_background #7aa2f7 +active_tab_foreground #16161e +inactive_tab_background #292e42 +inactive_tab_foreground #545c7e +#tab_bar_background #15161e + +# Windows +active_border_color #7aa2f7 +inactive_border_color #292e42 + +# normal +color0 #15161e +color1 #c94448 +color2 #9ece6a +color3 #e0af68 +color4 #7aa2f7 +color5 #bb9af7 +color6 #7dcfff +color7 #a9b1d6 + +# bright +color8 #414868 +color9 #f2201f +color10 #9ece6a +color11 #e0af68 +color12 #7aa2f7 +color13 #bb9af7 +color14 #7dcfff +color15 #c0caf5 + +# extended colors +color16 #ff9e64 +color17 #db4b4b + +shell zsh diff --git a/nvim/init.lua b/nvim/init.lua index 2460ce5..45eaafe 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -9,18 +9,17 @@ require("settings.pairs") require("settings.indentline") require("settings.project") require("settings.dashboard") -require("settings.null-ls") require("settings.rainbow") require("settings.dap") require("settings.autocommands") +require("settings.telescope") require("settings.keymaps") require("settings.barbar") -- simple plugins that don't make sense to put in a seperate file, would clutter too much require("gitsigns").setup() require("feline").setup() -require("telescope").setup({}) -require("telescope").load_extension("fzy_native") require("impatient").enable_profile() require("nightfox") require('Comment').setup() +require("toggleterm").setup() diff --git a/nvim/lua/settings/dashboard.lua b/nvim/lua/settings/dashboard.lua index 32079c4..5cb71d8 100644 --- a/nvim/lua/settings/dashboard.lua +++ b/nvim/lua/settings/dashboard.lua @@ -14,10 +14,11 @@ dashboard.section.header.val = { } dashboard.section.buttons.val = { dashboard.button("f", " Find file", ":Telescope find_files "), + dashboard.button("b", " Open File Browser", ":Telescope file_browser"), dashboard.button("e", " New file", ":ene startinsert "), dashboard.button("p", " Find project", ":Telescope project "), dashboard.button("r", " Recently used files", ":Telescope oldfiles "), - dashboard.button("t", " Find text", ":Telescope live_grep "), + dashboard.button("t", " Zoxide", ":Telescope zoxide list "), dashboard.button("c", " Configuration", ":e ~/.config/nvim/init.lua "), dashboard.button("q", " Quit Neovim", ":qa"), } diff --git a/nvim/lua/settings/keymaps.lua b/nvim/lua/settings/keymaps.lua index 91cb8fb..d7c1afa 100644 --- a/nvim/lua/settings/keymaps.lua +++ b/nvim/lua/settings/keymaps.lua @@ -2,10 +2,6 @@ local opts = { noremap = true, silent = true } local term_opts = { silent = true } local keymap = vim.api.nvim_set_keymap --- space leader -vim.g.mapleader = " " -keymap("n", "", "", { silent = true, noremap = false }) - -- debug keymap("n", "", ':lua require("dap").toggle_breakpoint()', opts) keymap("n", "", ':lua require("dap").step_over()', opts) @@ -15,8 +11,8 @@ keymap("n", "", ':lua require("dap").continue()', opts) keymap("n", "", ':lua require("dap").close() :lua require("dapui").toggle()', opts) -- file tree -keymap("n", "t", ':lua require("nvim-tree").toggle()', opts) -keymap("n", "f", ':lua require("nvim-tree").focus()', opts) +keymap("n", "t", ":ToggleTerm", opts) +keymap("n", "n", ':lua require("nvim-tree").toggle()', opts) -- tab switching keymap("n", "", ":BufferPrev", opts) @@ -24,14 +20,22 @@ keymap("n", "", ":BufferNext", opts) -- formatting keymap("n", "", ":lua vim.lsp.buf.format { async = true }", opts) +keymap("n", "q", ":Telescope lsp_definitions", opts) +keymap("n", "w", ":Telescope lsp_references", opts) +keymap("n", "e", ":Telescope lsp_type_definitions", opts) +keymap("n", "a", ":lua vim.lsp.buf.code_action()", opts) +keymap("n", "s", ":lua vim.lsp.buf.signature_help()", opts) -- telescope +keymap("n", "fb", ":Telescope file_browser", {}) +keymap("n", "fc", ":Cheatsheet", {}) keymap("n", "ff", ":lua require('telescope.builtin').find_files()", {}) keymap("n", "fg", ":lua require('telescope.builtin').live_grep()", {}) -keymap("n", "fb", ":lua require('telescope.builtin').buffers()", {}) keymap("n", "fh", ":lua require('telescope.builtin').help_tags()", {}) keymap("n", "fp", ":lua require'telescope'.extensions.project.project{}", { noremap = true, silent = true }) +vim.keymap.set("n", "z", ":lua require('telescope').extensions.zoxide.list{}") + -- trouble keymap("n", "", "TroubleToggle", term_opts) require("trouble").setup({ @@ -41,15 +45,3 @@ require("trouble").setup({ }, }) --- LSP -local on_attach = function(client, bufnr) - vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") - local opts = { noremap = true, silent = true, buffer = bufnr } - keymap("n", "h", "lua vim.lsp.buf.declaration()", opts) - keymap("n", "j", "lua vim.lsp.buf.definition()", opts) - keymap("n", "k", "lua vim.lsp.buf.implementation()", opts) - keymap("n", "l", "lua vim.lsp.buf.references()", opts) - keymap("n", ";", "lua vim.lsp.buf.code_action()", opts) - keymap("n", "u", "lua vim.lsp.buf.signature_help()", opts) - keymap("n", "g", "lua vim.lsp.buf.hover()", opts) -end diff --git a/nvim/lua/settings/lsp.lua b/nvim/lua/settings/lsp.lua index f93d10d..22c08be 100644 --- a/nvim/lua/settings/lsp.lua +++ b/nvim/lua/settings/lsp.lua @@ -18,10 +18,8 @@ require("mason-lspconfig").setup({ "cssls", -- css "html", -- html "clangd", -- cpp / c - "tsserver", -- javascript / typescript "sumneko_lua", -- lua "pyright", -- python - "rust_analyzer", -- rust "cmake", -- cmake "bashls", -- shell "ansiblels", -- ansible @@ -32,12 +30,50 @@ require("mason-lspconfig").setup({ }) local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) +capabilities.textDocument.completion.completionItem.snippetSupport = true + +-- LSP +local on_attach = function(client, bufnr) + vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") + local optslsp = { noremap = false, silent = true, buffer = bufnr } +end require("mason-lspconfig").setup_handlers({ function(server_name) -- default handler (optional) require("lspconfig")[server_name].setup({ capabilities = capabilities, on_attach = on_attach, + vim.lsp.diagnostic.on_publish_diagnostics, { + -- Disable virtual_text + virtual_text = true, + } + }) end, }) + +require("lsp-format").setup {} + +local on_attach = function(client) + require("lsp-format").on_attach(client) +end + +-- special server setups +require("clangd_extensions").setup() +require("rust-tools").setup({ + server = { + standalone = false, + root_dir = require('lspconfig').util.find_git_ancestor, + loadOutputiDirs = false, + } +}) +require("typescript").setup({ + disable_commands = false, -- prevent the plugin from creating Vim commands + debug = false, -- enable debug logging for commands + go_to_source_definition = { + fallback = true, -- fall back to standard LSP definition on failure + }, + server = { -- pass options to lspconfig's setup method + on_attach = on_attach, + }, +}) diff --git a/nvim/lua/settings/null-ls.lua b/nvim/lua/settings/null-ls.lua deleted file mode 100644 index fbbb432..0000000 --- a/nvim/lua/settings/null-ls.lua +++ /dev/null @@ -1,36 +0,0 @@ -local null_ls = require("null-ls") - -require("mason-null-ls").setup({ - ensure_installed = { - "prettierd", - "clang_format", - "shellharden", - "sql_formatter", - "fixjson", - "autopep8", - "stylua", - "rustfmt", - }, -}) - -null_ls.setup({ - on_attach = function(client, bufnr) - if client.server_capabilities.documentRangeFormattingProvider then - vim.cmd("xnoremap f :lua vim.lsp.buf.range_formatting({})") - end - end, - sources = { - require("null-ls").builtins.formatting.prettierd.with({ - env = { - PRETTIERD_DEFAULT_CONFIG = vim.fn.expand("~/.config/nvim/lua/settings/.prettierrc"), - },} - ), - require("null-ls").builtins.formatting.clang_format, - require("null-ls").builtins.formatting.shellharden, - require("null-ls").builtins.formatting.sql_formatter, - require("null-ls").builtins.formatting.fixjson, - require("null-ls").builtins.formatting.autopep8, - require("null-ls").builtins.formatting.stylua, - require("null-ls").builtins.formatting.rustfmt, - }, -}) diff --git a/nvim/lua/settings/options.lua b/nvim/lua/settings/options.lua index 19a30f1..61acc01 100644 --- a/nvim/lua/settings/options.lua +++ b/nvim/lua/settings/options.lua @@ -23,11 +23,16 @@ local options = { syntax = "off", spelllang = "en_us", mousemodel = "popup_setpos", + shell = "/usr/bin/zsh" } vim.g.mkdp_browser = '/usr/bin/firefox' vim.g.mkdp_auto_start = 1 +-- space leader +vim.g.mapleader = " " +vim.keymap.set("n", "", "", { silent = true, noremap = false }) + for k, v in pairs(options) do vim.opt[k] = v end diff --git a/nvim/lua/settings/plugins.lua b/nvim/lua/settings/plugins.lua index 84c4813..2a41e79 100644 --- a/nvim/lua/settings/plugins.lua +++ b/nvim/lua/settings/plugins.lua @@ -11,8 +11,6 @@ Plug("nvim-lua/plenary.nvim") -- library, don't delete Plug("williamboman/mason.nvim") -- lsp and dap Plug("williamboman/mason-lspconfig.nvim") -- lsp to mason bridge Plug("neovim/nvim-lspconfig") -- nvim lsp -Plug("jose-elias-alvarez/null-ls.nvim") -- enables formatters -Plug("jayp0521/mason-null-ls.nvim") -- mason to formatter Plug("mfussenegger/nvim-dap") -- debugging capabilities Plug("rcarriga/nvim-dap-ui") -- debug ui Plug("theHamsta/nvim-dap-virtual-text") -- more debug ui @@ -43,9 +41,21 @@ Plug("nvim-telescope/telescope-ui-select.nvim") -- telescope ui Plug("nvim-telescope/telescope-file-browser.nvim") -- telescope file browser Plug("nvim-telescope/telescope-fzy-native.nvim") -- telescope fuzzy search Plug('nvim-telescope/telescope-project.nvim') -- telescope projects +Plug('nvim-telescope/telescope-symbols.nvim') -- symbol picker +Plug('nvim-telescope/telescope-file-browser.nvim') -- telescope file browser +Plug('nvim-telescope/telescope-dap.nvim') -- dap UI for telescope +Plug('benfowler/telescope-luasnip.nvim') -- telescope luasnip integration +Plug('sudormrfbin/cheatsheet.nvim') -- cheatsheet for keymaps +Plug('jvgrootveld/telescope-zoxide') -- zoxide integration +Plug('ThePrimeagen/harpoon') -- harpoonman Plug 'folke/trouble.nvim' -- provides warning/error explanation tab +Plug('akinsho/toggleterm.nvim',{ ["tag"] = "*" }) -- better terminal integration Plug("iamcco/markdown-preview.nvim", -- markdown preview { ["do"] = "cd app && yarn install" }) +Plug('p00f/clangd_extensions.nvim') -- clangd_extensions +Plug('jose-elias-alvarez/typescript.nvim') -- typescript extensions +Plug('kdarkhan/rust-tools.nvim') -- rust extensions Plug('preservim/tagbar') -- tags on the right +Plug('lukas-reineke/lsp-format.nvim') vim.call("plug#end") diff --git a/nvim/lua/settings/telescope.lua b/nvim/lua/settings/telescope.lua new file mode 100644 index 0000000..40bdf1a --- /dev/null +++ b/nvim/lua/settings/telescope.lua @@ -0,0 +1,35 @@ + +local t = require("telescope") +local z_utils = require("telescope._extensions.zoxide.utils") + +-- Configure the extension +t.setup({ + extensions = { + zoxide = { + prompt_title = "[ Queries ]", + mappings = { + default = { + after_action = function(selection) + print("Update to (" .. selection.z_score .. ") " .. selection.path) + end + }, + [""] = { + before_action = function(selection) print("before C-s") end, + action = function(selection) + vim.cmd("edit " .. selection.path) + end + }, + [""] = { action = z_utils.create_basic_command("split") }, + }, + }, + }, +}) + +-- Load the extension +t.load_extension('zoxide') + +-- Add a mapping +require("telescope").load_extension("fzy_native") +require("telescope").load_extension "file_browser" +require('telescope').load_extension('dap') +require("telescope").load_extension('harpoon')