diff --git a/after/plugin/alpha.lua b/after/plugin/alpha.lua index b05fdf8..99b7558 100644 --- a/after/plugin/alpha.lua +++ b/after/plugin/alpha.lua @@ -22,7 +22,7 @@ dashboard.section.buttons.val = { dashboard.button( "e", " Explorer", - "Explore" + "Oil" ), dashboard.button( "c", diff --git a/after/plugin/colors.lua b/after/plugin/colors.lua index b6b0f9a..156ebba 100644 --- a/after/plugin/colors.lua +++ b/after/plugin/colors.lua @@ -1,8 +1,9 @@ function ColorMyPencils(color) -color = color or "rose-pine" -vim.cmd.colorscheme(color) + color = color or "rose-pine" + vim.cmd.colorscheme(color) -vim.api.nvim_set_hl(0,"Normal", { bg = "none" }) -vim.api.nvim_set_hl(0,"NormalFloat", { bg = "none" }) + vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) + vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) end + ColorMyPencils(); diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua index c8be042..dad3624 100644 --- a/after/plugin/lsp.lua +++ b/after/plugin/lsp.lua @@ -4,70 +4,74 @@ lsp.preset("recommended") require("mason").setup({}) require("mason-lspconfig").setup({ - ensure_installed = { + ensure_installed = { "ts_ls", - "eslint", - "lua_ls", - "rust_analyzer", + "eslint", + "lua_ls", + "rust_analyzer", "ast_grep" - }, - handlers = { - function(server_name) - require("lspconfig")[server_name].setup({}) - end, - } + }, + handlers = { + function(server_name) + require("lspconfig")[server_name].setup({}) + end, + } }) local cmp = require('cmp') cmp.setup({ - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.confirm({ select = true }), - [""] = cmp.mapping.complete(), - }), - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) - end, - }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.complete(), + }), + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, }) lsp.extend_lspconfig() lsp.set_preferences({ - sign_icons = { } + sign_icons = {} }) lsp.on_attach(function(client, bufnr) -lsp.default_keymaps({buffer = bufnr}) + lsp.default_keymaps({ buffer = bufnr }) - local opts = {buffer = bufnr, remap = false} + local opts = { buffer = bufnr, remap = false } - vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) - vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts) - vim.keymap.set("n", "vws", function() vim.lsp.buf.workspace_symbol() end, opts) - vim.keymap.set("n", "vd", function() vim.diagnostic.open_float() end, opts) - vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts) - vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts) - vim.keymap.set("n", "vca", function() vim.lsp.buf.code_action() end, opts) - vim.keymap.set("n", "vrn", function() vim.lsp.buf.rename() end, opts) - vim.keymap.set("i", "", function() vim.lsp.buf.signature_help() end, opts) + local builtin = require('telescope.builtin') + + vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts) + vim.keymap.set("n", "gd", builtin.lsp_definitions, {}) + vim.keymap.set("n", "gd", builtin.lsp_definitions, {}) + vim.keymap.set('n', 'cf', builtin.lsp_incoming_calls) + vim.keymap.set("n", "vws", function() vim.lsp.buf.workspace_symbol() end, opts) + vim.keymap.set("n", "vd", function() vim.diagnostic.open_float() end, opts) + vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts) + vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts) + vim.keymap.set("n", "vca", function() vim.lsp.buf.code_action() end, opts) + vim.keymap.set("n", "vrn", function() vim.lsp.buf.rename() end, opts) + vim.keymap.set("i", "", function() vim.lsp.buf.signature_help() end, opts) end) lsp.setup() -- Function to restart all active LSP clients local function restart_lsp() - for _, client in pairs(vim.lsp.get_active_clients()) do - client.stop() - end - vim.cmd("edit") -- Reload the current buffer to reattach the LSP clients + for _, client in pairs(vim.lsp.get_active_clients()) do + client.stop() + end + vim.cmd("edit") -- Reload the current buffer to reattach the LSP clients end -- Create a Neovim command to restart LSP diff --git a/after/plugin/oil.lua b/after/plugin/oil.lua new file mode 100644 index 0000000..e69de29 diff --git a/after/plugin/presense.lua b/after/plugin/presense.lua index 6659e2b..fc1bf59 100644 --- a/after/plugin/presense.lua +++ b/after/plugin/presense.lua @@ -20,3 +20,21 @@ require("presence").setup({ workspace_text = "Working on %s", -- Format string rendered when in a git repository (either string or function(project_name: string|nil, filename: string): string) line_number_text = "Line %s" --"Line %s out of %s", -- Format string rendered when `enable_line_number` is set to true (either string or function(line_number: number, line_count: number): string) }) + +local is_presence_active = true + +function ToggleDiscordPresence() + local presence = package.loaded.presence + if is_presence_active then + presence:cancel() + is_presence_active = false + print("Discord Presence: Off") + else + is_presence_active = true + presence:update() + print("Discord Presence: On") + end +end + +-- Map it to a key (e.g., dp for "Discord Presence") +vim.keymap.set("n", "dp", ToggleDiscordPresence, { desc = "Toggle Discord Presence" }) diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua index 7b001ee..ab12a74 100644 --- a/after/plugin/telescope.lua +++ b/after/plugin/telescope.lua @@ -1,8 +1,36 @@ local builtin = require('telescope.builtin') -vim.keymap.set("n", "pf", builtin.find_files, {}) +vim.keymap.set("n", "pf", function() + builtin.find_files({ + hidden = true, + file_ignore_patterns = { "%.git/", "%.cache", "dist/", "target/", ".vscode/", "node_modules/", "%.o", "lazy-lock.json" } + }) +end, {}) +vim.keymap.set('n', 'bf', builtin.buffers, { desc = 'Telescope buffers' }) vim.keymap.set("n", "", builtin.git_files, {}) -vim.keymap.set("n", "ps", function() - builtin.grep_string({ search = vim.fn.input("Grep > ")}); +vim.keymap.set("n", "ps", function() + builtin.grep_string({ search = vim.fn.input("Grep > ") }); end) +local actions = require('telescope.actions') + +require("telescope").setup({ + defaults = { + preview = { + treesitter = false, + }, + mappings = { + i = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + }, + n = { + ["q"] = actions.close, + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + }, + }, + -- path_display = { "smart" }, + -- layout_strategy = "vertical", + }, +}) diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua index bebd8f4..c2dd96c 100644 --- a/after/plugin/treesitter.lua +++ b/after/plugin/treesitter.lua @@ -1,37 +1,8 @@ - - -require'nvim-treesitter'.setup { - -- A list of parser names, or "all" (the listed parsers MUST always be installed) - ensure_installed = { "c", "go", "lua", "vim", "vimdoc", "query", "markdown", "markdown_inline", "javascript", "typescript", "rust"}, - - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, - - -- Automatically install missing parsers when entering buffer - -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally - auto_install = false, - - highlight = { - enable = true, - - -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to - -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is - -- the name of the parser) - -- list of language that will be disabled - -- disable = {}, - -- Or a function for more flexibility, e.g. to disable slow treesitter highlight for large files - -- disable = function(lang, buf) - -- local max_filesize = 100 * 1024 -- 100 KB - -- local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) - -- if ok and stats and stats.size > max_filesize then - -- return true - -- end - -- end, - - -- Setting this to true will run `:h syntax` and tree-sitter at the same time. - -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). - -- Using this option may slow down your editor, and you may see some duplicate highlights. - -- Instead of true it can also be a list of languages - additional_vim_regex_highlighting = false, - }, -} +require("nvim-treesitter").setup({ + ensure_installed = { + "c", "go", "lua", "vim", "vimdoc", "query", "markdown", "markdown_inline", "javascript", "typescript", "rust" + }, + sync_install = true, + highlight = { enable = true }, + indent = { enable = false }, +}) diff --git a/after/queries/typescript/highlights.scm b/after/queries/typescript/highlights.scm new file mode 100644 index 0000000..e69de29 diff --git a/init.lua b/init.lua index 3017b57..dd50cbb 100644 --- a/init.lua +++ b/init.lua @@ -1,12 +1 @@ require("nami") - --- local ensure_packer = function() --- local fn = vim.fn --- local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' --- if fn.empty(fn.glob(install_path)) > 0 then --- fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) --- vim.cmd [[packadd packer.nvim]] --- end --- end --- --- ensure_packer() diff --git a/lazy-lock.json b/lazy-lock.json index 5ca9d05..e521e08 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,25 +1,26 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "LuaSnip": { "branch": "master", "commit": "dae4f5aaa3574bd0c2b9dd20fb9542a02c10471c" }, - "alpha-nvim": { "branch": "main", "commit": "3979b01cb05734331c7873049001d3f2bb8477f4" }, + "LuaSnip": { "branch": "master", "commit": "a62e1083a3cfe8b6b206e7d3d33a51091df25357" }, + "alpha-nvim": { "branch": "main", "commit": "6c6a89d5b068b5251c8bdf0dd57bb921bcfeeb09" }, "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, "flutter-tools.nvim": { "branch": "main", "commit": "677cc07c16e8b89999108d2ebeefcfc5f539b73c" }, "harpoon": { "branch": "harpoon2", "commit": "87b1a3506211538f460786c23f98ec63ad9af4e5" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, "lsp-zero.nvim": { "branch": "v3.x", "commit": "77550f2f6cbf0959ef1583d845661af075f3442b" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "ae609525ddf01c153c39305730b1791800ffe4fe" }, - "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, - "mini.align": { "branch": "main", "commit": "6d8a6ca3a0fd313938374abccb50cad026229db3" }, - "nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "0a3b42c3e503df87aef6d6513e13148381495c3a" }, + "mason.nvim": { "branch": "main", "commit": "b03fb0f20bc1d43daf558cda981a2be22e73ac42" }, + "mini.icons": { "branch": "main", "commit": "bac6317300e205335df425296570d84322730067" }, + "nvim-cmp": { "branch": "main", "commit": "a1d504892f2bc56c2e79b65c6faded2fd21f3eca" }, "nvim-ghost.nvim": { "branch": "main", "commit": "bdba2a8ad0eec84379d65e7aa9b76a17b11b653a" }, - "nvim-lspconfig": { "branch": "master", "commit": "66fd02ad1c7ea31616d3ca678fa04e6d0b360824" }, - "nvim-treesitter": { "branch": "main", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" }, - "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "nvim-lspconfig": { "branch": "master", "commit": "4b7fbaa239c5db6b36f424a4521ca9f1a401be33" }, + "nvim-treesitter": { "branch": "main", "commit": "4916d6592ede8c07973490d9322f187e07dfefac" }, + "oil.nvim": { "branch": "master", "commit": "0fcc83805ad11cf714a949c98c605ed717e0b83e" }, + "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, - "quick-scope": { "branch": "master", "commit": "6cee1d9e0b9ac0fbffeb538d4a5ba9f5628fabbc" }, - "rose-pine": { "branch": "main", "commit": "cf2a288696b03d0934da713d66c6d71557b5c997" }, - "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, - "undotree": { "branch": "master", "commit": "fc28931fbfba66ab75d9af23fe46ffbbb9de6e8c" }, - "vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" } + "rose-pine": { "branch": "main", "commit": "9504524e5ed0e326534698f637f9d038ba4cd0ee" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" }, + "telescope.nvim": { "branch": "master", "commit": "3333a52ff548ba0a68af6d8da1e54f9cd96e9179" }, + "undotree": { "branch": "master", "commit": "6fa6b57cda8459e1e4b2ca34df702f55242f4e4d" }, + "vim-fugitive": { "branch": "master", "commit": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0" }, + "vim-maximizer": { "branch": "master", "commit": "2e54952fe91e140a2e69f35f22131219fcd9c5f1" } } diff --git a/lua/nami/lazy.lua b/lua/nami/lazy.lua index 55022d6..e470e9d 100755 --- a/lua/nami/lazy.lua +++ b/lua/nami/lazy.lua @@ -14,16 +14,15 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) --- opts.rocks.enabled = false vim.g.mapleader = " " local plugins = { - -- "wbthomason/packer.nvim", { "nvim-telescope/telescope.nvim", - version = "0.1.8", - -- or , branch = "0.1.x", - dependencies = { { "nvim-lua/plenary.nvim" } } + version = "0.2.1", + dependencies = { { "nvim-lua/plenary.nvim" }, + { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, + }, }, { "rose-pine/neovim", @@ -32,56 +31,43 @@ local plugins = { vim.cmd("colorscheme rose-pine") end }, - { - "nvim-treesitter/nvim-treesitter", - tag = "v0.10.0", - lazy = false, - build = ":TSUpdate" - -- build = function() - -- -- local ts_update = require("nvim-treesitter.install").update({ with_sync = true }) - -- -- ts_update() - -- end - }, + { "nvim-treesitter/nvim-treesitter", branch = "main", lazy = false, build = ":TSUpdate" }, { "ThePrimeagen/harpoon", branch = "harpoon2", dependencies = { "nvim-lua/plenary.nvim" } }, - -- "theprimeagen/harpoon", "mbbill/undotree", "tpope/vim-fugitive", - -- ("christoomey/vim-tmux-navigator") - -- "huggingface/llm.nvim", "subnut/nvim-ghost.nvim", - "unblevable/quick-scope", - -- ({ - -- "kr40/nvim-macros", - -- cmd = {"MacroSave", "MacroYank", "MacroSelect", "MacroDelete"}, - -- opts = { - -- json_file_path = vim.fs.normalize(vim.fn.stdpath("config") .. "/macros.json"), -- Location where the macros will be stored - -- default_macro_register = "q", -- Use name default register for :MacroYank and :MacroSave and :MacroSelect Raw functions - -- json_formatter = "none", -- can be "none" | "jq" | "yq" used to pretty print the json file (jq or yq must be installed!) - -- } - -- }) + -- "unblevable/quick-scope", "andweeb/presence.nvim", "numToStr/Comment.nvim", + -- "echasnovski/mini.align", { - "epwalsh/obsidian.nvim", - version = "*", - dependencies = { - "nvim-lua/plenary.nvim" + 'stevearc/oil.nvim', + ---@module 'oil' + ---@type oil.SetupOpts + opts = {}, + -- Optional dependencies + dependencies = { { "nvim-mini/mini.icons", opts = {} } }, + -- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if you prefer nvim-web-devicons + -- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations. + lazy = false, + }, + { + -- The tmux `Prefix + z` behaviour + "szw/vim-maximizer", + keys = { + { "z", "MaximizerToggle" }, } }, - "echasnovski/mini.align", - -- use {"kevinhwang91/nvim-ufo", dependencies = "kevinhwang91/promise-async"} { "VonHeikemen/lsp-zero.nvim", branch = "v3.x", dependencies = { - --- Uncomment the two plugins below if you want to manage the language servers from neovim { "williamboman/mason.nvim" }, { "williamboman/mason-lspconfig.nvim" }, - { "neovim/nvim-lspconfig" }, { "hrsh7th/nvim-cmp" }, { "hrsh7th/cmp-nvim-lsp" }, @@ -92,19 +78,14 @@ local plugins = { "nvim-flutter/flutter-tools.nvim", dependencies = { "nvim-lua/plenary.nvim", - -- "stevearc/dressing.nvim", -- optional for vim.ui.select }, }, - { "goolord/alpha-nvim", lazy = true, event = "VimEnter", - -- config = function() - -- require("user.plugins.settings.alpha") - -- end, cmd = "Alpha", - }, -- Splash Screen + }, } require("lazy").setup(plugins, {}) diff --git a/lua/nami/remap.lua b/lua/nami/remap.lua index d3b1908..1cb6dff 100644 --- a/lua/nami/remap.lua +++ b/lua/nami/remap.lua @@ -7,7 +7,9 @@ vim.cmd("command! ON ObsidianNew") vim.keymap.set("n", "c", ":w:!cargorun") -vim.keymap.set("n", "pv", vim.cmd.Ex) +-- vim.keymap.set("n", "pv", vim.cmd.Ex) +vim.keymap.set("n", "pv", "Oil", { desc = "Open parent directory" }) +vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }) vim.keymap.set("v", "J", ":m '>+1gv=gv") vim.keymap.set("v", "K", ":m '<-2gv=gv") @@ -32,22 +34,60 @@ vim.keymap.set("v", "d", "\"_d") vim.keymap.set("i", "", "") vim.keymap.set("n", "Q", "") -vim.keymap.set("n", "", "silent !tmux neww tmux-sessionizer") +vim.keymap.set("n", "", "silent !tmux display-popup -E \"tmuxss -i\"") vim.keymap.set("n", "f", function() vim.lsp.buf.format() end) --- vim.keymap.set("n", "", "cnextzz") -- vim.keymap.set("n", "", "cprevzz") +-- vim.keymap.set("n", "", "cnextzz") -- vim.keymap.set("n", "k", "lnextzz") -- vim.keymap.set("n", "j", "lprevzz") vim.keymap.set("n", "s", ":%s/\\<\\>//gI") vim.keymap.set("n", "x", "!chmod +x %", { silent = true }) -for _, mode in ipairs({"n", "v", "i"}) do +for _, mode in ipairs({ "n", "v", "i" }) do vim.keymap.set(mode, "", function() end) vim.keymap.set(mode, "<2-RightMouse>", function() end) vim.keymap.set(mode, "<3-RightMouse>", function() end) vim.keymap.set(mode, "<4-RightMouse>", function() end) end + +vim.keymap.set("n", "", "tabnext +") +vim.keymap.set("n", "", "tabnext -") +vim.keymap.set("n", "", "tabnew") +-- vim.keymap.del("n", "d") +-- vim.keymap.del("n", "") +vim.keymap.set("n", "", "tabclose") + +vim.keymap.set("n", "l", "source %") +vim.keymap.set("n", "l", ":.lua") +vim.keymap.set("v", "l", ":lua") + +local function swap_words() + local start = vim.fn.getpos("'<")[2] + local finish = vim.fn.getpos("'>")[2] + + local w1 = vim.fn.input("Word 1: ") + local w2 = vim.fn.input("Word 2: ") + + if w1 == "" or w2 == "" then + return + end + + local lines = vim.api.nvim_buf_get_lines(0, start - 1, finish, false) + + for i, line in ipairs(lines) do + line = line:gsub(vim.pesc(w1), "__TMP__") + line = line:gsub(vim.pesc(w2), w1) + line = line:gsub("__TMP__", w2) + lines[i] = line + end + + vim.api.nvim_buf_set_lines(0, start - 1, finish, false, lines) +end + +vim.keymap.set("v", "ws", swap_words, { desc = "Swap two words in selection" }) +vim.keymap.set("n", "ws", swap_words, { desc = "Swap two words in selection" }) + diff --git a/lua/nami/set.lua b/lua/nami/set.lua index bbb2078..5645554 100644 --- a/lua/nami/set.lua +++ b/lua/nami/set.lua @@ -39,7 +39,7 @@ vim.opt.scrolloff = 8 vim.opt.signcolumn = "yes" vim.opt.isfname:append("@-@") --- vim.opt_local.conceallevel = 1 +vim.opt_local.conceallevel = 1 vim.opt.updatetime = 50