From 0142dc96c8afd3ac9935e9ac8e12b9b272baed19 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Mon, 19 Dec 2022 01:01:18 +0000 Subject: [PATCH] refactor(lvim): OOP'ify my config --- dot_config/lvim/config.lua | 311 +----------------- dot_config/lvim/lua/hammy/formatter.lua | 8 + dot_config/lvim/lua/hammy/init.lua | 21 ++ dot_config/lvim/lua/hammy/linter.lua | 18 + dot_config/lvim/lua/hammy/lsp/haskell.lua | 5 + dot_config/lvim/lua/hammy/lsp/init.lua | 60 ++++ dot_config/lvim/lua/hammy/lsp/rust.lua | 102 ++++++ dot_config/lvim/lua/hammy/packer.lua | 93 ++++++ dot_config/lvim/lua/hammy/plugin/cmp.lua | 10 + .../lvim/lua/hammy/plugin/dashboard.lua | 11 + dot_config/lvim/lua/hammy/plugin/init.lua | 14 + dot_config/lvim/lua/hammy/plugin/nvimtree.lua | 2 + .../lvim/lua/hammy/plugin/telescope.lua | 38 +++ .../lvim/lua/hammy/plugin/treesitter.lua | 3 + dot_config/lvim/lua/hammy/remap.lua | 32 ++ dot_config/lvim/lua/hammy/set.lua | 14 + dot_config/lvim/stylua.toml | 7 + 17 files changed, 439 insertions(+), 310 deletions(-) create mode 100644 dot_config/lvim/lua/hammy/formatter.lua create mode 100644 dot_config/lvim/lua/hammy/init.lua create mode 100644 dot_config/lvim/lua/hammy/linter.lua create mode 100644 dot_config/lvim/lua/hammy/lsp/haskell.lua create mode 100644 dot_config/lvim/lua/hammy/lsp/init.lua create mode 100644 dot_config/lvim/lua/hammy/lsp/rust.lua create mode 100644 dot_config/lvim/lua/hammy/packer.lua create mode 100644 dot_config/lvim/lua/hammy/plugin/cmp.lua create mode 100644 dot_config/lvim/lua/hammy/plugin/dashboard.lua create mode 100644 dot_config/lvim/lua/hammy/plugin/init.lua create mode 100644 dot_config/lvim/lua/hammy/plugin/nvimtree.lua create mode 100644 dot_config/lvim/lua/hammy/plugin/telescope.lua create mode 100644 dot_config/lvim/lua/hammy/plugin/treesitter.lua create mode 100644 dot_config/lvim/lua/hammy/remap.lua create mode 100644 dot_config/lvim/lua/hammy/set.lua create mode 100644 dot_config/lvim/stylua.toml diff --git a/dot_config/lvim/config.lua b/dot_config/lvim/config.lua index a6c8429..7803db5 100644 --- a/dot_config/lvim/config.lua +++ b/dot_config/lvim/config.lua @@ -1,310 +1 @@ --- Vim Options -vim.opt.timeoutlen = 500 -vim.opt.relativenumber = true -vim.opt.laststatus = 3 -vim.opt.pumheight = 20 -vim.opt.clipboard = "" -vim.opt.lazyredraw = true -vim.opt.showtabline = 0 -vim.opt.completeopt = [[menuone,noinsert,noselect]] -lvim.log.level = "warn" -lvim.format_on_save = false -lvim.colorscheme = "catppuccin" -lvim.leader = "space" - --- unmapping defaults -lvim.keys.normal_mode[""] = false -lvim.keys.normal_mode[""] = false -lvim.keys.normal_mode[""] = false -lvim.keys.insert_mode[""] = false -lvim.keys.insert_mode[""] = false - --- navigation -lvim.keys.normal_mode[""] = "j" -lvim.keys.normal_mode[""] = "k" -lvim.keys.normal_mode[""] = "l" -lvim.keys.normal_mode[""] = "h" - --- cmp -local cmp = require("cmp") -local mappings = { - [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), -} -lvim.builtin.cmp.cmdline.enable = true -lvim.builtin.cmp.mapping = vim.tbl_deep_extend("keep", mappings, - lvim.builtin.cmp.mapping) - --- lsp -local lsp_diagnostics = { - update_in_insert = true, - float = { border = "rounded" }, -} -local buffer_mappings = { - normal_mode = { - ["ge"] = { - function() require("telescope.builtin").diagnostics() end, - "Display Workplace Diagnostics", - }, - ["gr"] = { - function() require("telescope.builtin").lsp_references() end, - "Goto References", - }, - ["gd"] = { - function() require("telescope.builtin").lsp_definitions() end, - "Goto Definitions", - }, - ["gI"] = { - function() require("telescope.builtin").lsp_implementations() end, - "Goto Implementations", - }, - }, -} -lvim.lsp.diagnostics = vim.tbl_deep_extend("keep", lsp_diagnostics, - lvim.lsp.diagnostics) -lvim.lsp.buffer_mappings = vim.tbl_deep_extend("keep", buffer_mappings, - lvim.lsp.buffer_mappings) - --- useful -lvim.keys.normal_mode[""] = "zz" -lvim.keys.normal_mode[""] = "zz" -lvim.keys.normal_mode[""] = "o" -lvim.keys.normal_mode["0"] = "^" -lvim.keys.normal_mode["[d"] = ":lua vim.diagnostic.goto_prev()" -lvim.keys.normal_mode["]d"] = ":lua vim.diagnostic.goto_next()" -lvim.keys.normal_mode["[c"] = ":lua require('gitsigns').prev_hunk()" -lvim.keys.normal_mode["]c"] = ":lua require('gitsigns').next_hunk()" - --- which-key -lvim.builtin.which_key.mappings["s"] = nil -lvim.builtin.which_key.mappings["f"] = { - name = "Find", - b = { "Telescope buffers", "Open Buffers" }, - f = { "Telescope find_files", "Find File" }, - h = { "Telescope help_tags", "Find Help" }, - H = { "Telescope highlights", "Find Highlights" }, - g = { "Telescope live_grep", "Find Text" }, - R = { "Telescope registers", "Find Registers" }, - k = { "Telescope keymaps", "Find Keymaps" }, - c = { - "Telescope current_buffer_fuzzy_find", - "Find Text In Current Buffer", - }, - C = { "Telescope commands", "Find Commands" }, - r = { "Telescope oldfiles", "Open Recent File" }, - p = { "Telescope projects", "Open Projects" }, - d = { "Easypick chezmoi", "Open Dotfiles" }, -} - -local _, actions = pcall(require, "telescope.actions") -lvim.builtin.telescope.defaults.prompt_prefix = "🔍 " -lvim.builtin.telescope.defaults.selection_caret = "> " -lvim.builtin.telescope.defaults.file_ignore_patterns = { ".git/" } -lvim.builtin.telescope.defaults.mappings = { - i = { - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - [""] = actions.cycle_history_next, - [""] = actions.cycle_history_prev, - }, - n = { - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - [""] = actions.preview_scrolling_down, - [""] = actions.preview_scrolling_up, - }, -} - -lvim.builtin.project.active = true -lvim.builtin.alpha.active = true -lvim.builtin.alpha.mode = "dashboard" -lvim.builtin.bufferline.active = false -lvim.builtin.breadcrumbs.active = true -lvim.builtin.terminal.active = false -lvim.builtin.indentlines.active = false -lvim.builtin.illuminate.active = false -lvim.builtin.treesitter.rainbow.enable = true -lvim.builtin.treesitter.highlight.enable = true -lvim.builtin.nvimtree.setup.view.side = "left" -lvim.builtin.nvimtree.setup.renderer.icons.show.git = true - -lvim.builtin.alpha.dashboard.section.header.val = { - [[ __ ]], - [[ ___ ___ ___ __ __ /\_\ ___ ___ ]], - [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]], - [[/\ \/\ \/\ __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]], - [[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]], - [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]], -} - --- if you don't want all the parsers change this to a table of the ones you want -lvim.builtin.treesitter.ensure_installed = { - "bash", - "c", - "javascript", - "json", - "lua", - "python", - "typescript", - "tsx", - "css", - "rust", - "java", - "haskell", - "markdown", - "markdown_inline", - "html", - "go", - "erlang", - "toml", -} - ----configure a server manually. !!Requires `:LvimCacheReset` to take effect!! -vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "hls" }) -local opts = { cmd = { "haskell-language-server-9.2.4", "--lsp" } } -- check the lspconfig documentation for a list of all possible options -require("lvim.lsp.manager").setup("hls", opts) -require("lspconfig.ui.windows").default_options.border = "rounded" - --- ---remove a server from the skipped list, e.g. eslint, or emmet_ls. !!Requires `:LvimCacheReset` to take effect!! ----see the full default list `:lua print(vim.inspect(lvim.lsp.automatic_configuration.skipped_servers))` --- ---`:LvimInfo` lists which server(s) are skipped for the current filetype --- lvim.lsp.automatic_configuration.skipped_servers = vim.tbl_filter(function(server) --- return server ~= "hls" --- end, lvim.lsp.automatic_configuration.skipped_servers) - --- -- you can set a custom on_attach function that will be used for all the language servers --- -- See --- lvim.lsp.on_attach_callback = function(client, bufnr) --- local function buf_set_option(...) --- vim.api.nvim_buf_set_option(bufnr, ...) --- end --- --Enable completion triggered by --- buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") --- end - -local formatters = require "lvim.lsp.null-ls.formatters" -formatters.setup { - { - command = "lua-format", - filetypes = { "lua" }, - extra_args = { - "--spaces-inside-table-braces", - "--indent-width=2", - "--tab-width=2", - "--continuation-indent-width=2", - "--chop-down-table", - "--extra-sep-at-table-end", - }, - }, -} - --- -- set additional linters --- local linters = require "lvim.lsp.null-ls.linters" --- linters.setup { --- { command = "flake8", filetypes = { "python" } }, --- { --- -- each linter accepts a list of options identical to https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md#Configuration --- command = "shellcheck", --- ---@usage arguments to pass to the formatter --- -- these cannot contain whitespaces, options such as `--line-width 80` become either `{'--line-width', '80'}` or `{'--line-width=80'}` --- extra_args = { "--severity", "warning" }, --- }, --- { --- command = "codespell", --- ---@usage specify which filetypes to enable. By default a providers will attach to all the filetypes it supports. --- filetypes = { "javascript", "python" }, --- }, --- } - --- Additional Plugins -lvim.plugins = { - { "andweeb/presence.nvim" }, - { "hrsh7th/cmp-cmdline" }, - { "gpanders/editorconfig.nvim" }, - { "p00f/nvim-ts-rainbow" }, - { "nvim-treesitter/playground" }, - { - "axkirillov/easypick.nvim", - config = function() - local easypick = require("easypick") - easypick.setup { - pickers = { - { - name = "chezmoi", - command = [[chezmoi managed -x encrypted -i files | awk '{ printf("%s/%s\n", "~", $0) }']], - opts = require('telescope.themes').get_dropdown({}), - }, - }, - } - end, - }, - { - 'stevearc/dressing.nvim', - config = function() - require("dressing").setup { input = { insert_only = false } } - end, - }, - { - "kylechui/nvim-surround", - tag = "*", -- Use for stability; omit to use `main` branch for the latest features - config = function() require("nvim-surround").setup() end, - }, - { - "catppuccin/nvim", - as = "catppuccin", - config = function() - local cp = require("catppuccin.palettes").get_palette() - - require("catppuccin").setup({ - flavour = "mocha", - compile_path = vim.fn.stdpath("cache") .. "/catppuccin", - transparent_background = true, - term_colors = true, - no_italic = true, - integrations = { - ts_rainbow = true, - which_key = true, - dap = { enabled = true, enable_ui = true }, - navic = { enabled = true, custom_bg = "NONE" }, - }, - color_overrides = { - mocha = { - base = "#000000", - mantle = "#000000", - surface2 = cp.subtext0, - overlay0 = cp.subtext0, - }, - }, - custom_highlights = { - ErrorMsg = { fg = cp.red, style = { "bold" } }, - LspInfoBorder = { link = "FloatBorder" }, - PmenuSel = { bg = cp.surface0 }, - FloatBorder = { fg = cp.overlay0, bg = "NONE" }, - TelescopeBorder = { link = "FloatBorder" }, - TelescopeMatching = { link = "TelescopeNormal" }, - TelescopeSelection = { fg = "NONE", bg = cp.surface0 }, - TelescopeTitle = { fg = cp.subtext0 }, - }, - }) - - vim.api.nvim_command "colorscheme catppuccin" - end, - }, -} - --- SOME PROPER CUSTOM CONFIGURATION -- - -vim.api.nvim_create_autocmd("BufWritePost", { - group = vim.api.nvim_create_augroup("editorconfig", { clear = true }), - pattern = "*.editorconfig", - desc = "Refresh open buffers configuration on .editorconfig save", - callback = function() - for _, buf in pairs(vim.api.nvim_list_bufs()) do - if vim.api.nvim_buf_is_valid(buf) then - require("editorconfig").config(buf) - end - end - end, -}) +require("hammy") diff --git a/dot_config/lvim/lua/hammy/formatter.lua b/dot_config/lvim/lua/hammy/formatter.lua new file mode 100644 index 0000000..725211d --- /dev/null +++ b/dot_config/lvim/lua/hammy/formatter.lua @@ -0,0 +1,8 @@ +local formatters = require("lvim.lsp.null-ls.formatters") + +formatters.setup({ + { + command = "stylua", + filetypes = { "lua" }, + }, +}) diff --git a/dot_config/lvim/lua/hammy/init.lua b/dot_config/lvim/lua/hammy/init.lua new file mode 100644 index 0000000..7f22324 --- /dev/null +++ b/dot_config/lvim/lua/hammy/init.lua @@ -0,0 +1,21 @@ +require("hammy.set") +require("hammy.remap") +require("hammy.formatter") +-- require("hammy.linter") +require("hammy.packer") +require("hammy.lsp") +require("hammy.plugin") + +-- Some "Proper" Custom Configuration -- +vim.api.nvim_create_autocmd("BufWritePost", { + group = vim.api.nvim_create_augroup("editorconfig", { clear = true }), + pattern = "*.editorconfig", + desc = "Refresh open buffers configuration on .editorconfig save", + callback = function() + for _, buf in pairs(vim.api.nvim_list_bufs()) do + if vim.api.nvim_buf_is_valid(buf) then + require("editorconfig").config(buf) + end + end + end, +}) diff --git a/dot_config/lvim/lua/hammy/linter.lua b/dot_config/lvim/lua/hammy/linter.lua new file mode 100644 index 0000000..f56b1d9 --- /dev/null +++ b/dot_config/lvim/lua/hammy/linter.lua @@ -0,0 +1,18 @@ +-- -- set additional linters +-- local linters = require "lvim.lsp.null-ls.linters" +-- linters.setup { +-- { command = "flake8", filetypes = { "python" } }, +-- { +-- -- each linter accepts a list of options identical to https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md#Configuration +-- command = "shellcheck", +-- ---@usage arguments to pass to the formatter +-- -- these cannot contain whitespaces, options such as `--line-width 80` become either `{'--line-width', '80'}` or `{'--line-width=80'}` +-- extra_args = { "--severity", "warning" }, +-- }, +-- { +-- command = "codespell", +-- ---@usage specify which filetypes to enable. By default a providers will attach to all the filetypes it supports. +-- filetypes = { "javascript", "python" }, +-- }, +-- } + diff --git a/dot_config/lvim/lua/hammy/lsp/haskell.lua b/dot_config/lvim/lua/hammy/lsp/haskell.lua new file mode 100644 index 0000000..fd956e9 --- /dev/null +++ b/dot_config/lvim/lua/hammy/lsp/haskell.lua @@ -0,0 +1,5 @@ +local opts = { + cmd = { "haskell-language-server-9.2.4", "--lsp" }, +} + +require("lvim.lsp.manager").setup("hls", opts) diff --git a/dot_config/lvim/lua/hammy/lsp/init.lua b/dot_config/lvim/lua/hammy/lsp/init.lua new file mode 100644 index 0000000..315d7e3 --- /dev/null +++ b/dot_config/lvim/lua/hammy/lsp/init.lua @@ -0,0 +1,60 @@ +require("hammy.lsp.haskell") +require("hammy.lsp.rust") + +require("lspconfig.ui.windows").default_options.border = "rounded" + +local lsp_diagnostics = { + update_in_insert = true, + float = { border = "rounded" }, +} +local buffer_mappings = { + normal_mode = { + ["ge"] = { + function() + require("telescope.builtin").diagnostics() + end, + "Display Workplace Diagnostics", + }, + ["gr"] = { + function() + require("telescope.builtin").lsp_references() + end, + "Goto References", + }, + ["gd"] = { + function() + require("telescope.builtin").lsp_definitions() + end, + "Goto Definitions", + }, + ["gI"] = { + function() + require("telescope.builtin").lsp_implementations() + end, + "Goto Implementations", + }, + }, +} + +lvim.lsp.diagnostics = vim.tbl_deep_extend("keep", lsp_diagnostics, lvim.lsp.diagnostics) +lvim.lsp.buffer_mappings = vim.tbl_deep_extend("keep", buffer_mappings, lvim.lsp.buffer_mappings) + +-- Requires `:LvimCacheReset` to take effect +vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "hls", "rust_analyzer" }) + +-- ---remove a server from the skipped list, e.g. eslint, or emmet_ls. !!Requires `:LvimCacheReset` to take effect!! +---see the full default list `:lua print(vim.inspect(lvim.lsp.automatic_configuration.skipped_servers))` +-- ---`:LvimInfo` lists which server(s) are skipped for the current filetype +-- lvim.lsp.automatic_configuration.skipped_servers = vim.tbl_filter(function(server) +-- return server ~= "hls" +-- end, lvim.lsp.automatic_configuration.skipped_servers) + +-- -- you can set a custom on_attach function that will be used for all the language servers +-- -- See +-- lvim.lsp.on_attach_callback = function(client, bufnr) +-- local function buf_set_option(...) +-- vim.api.nvim_buf_set_option(bufnr, ...) +-- end +-- --Enable completion triggered by +-- buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") +-- end diff --git a/dot_config/lvim/lua/hammy/lsp/rust.lua b/dot_config/lvim/lua/hammy/lsp/rust.lua new file mode 100644 index 0000000..70c1692 --- /dev/null +++ b/dot_config/lvim/lua/hammy/lsp/rust.lua @@ -0,0 +1,102 @@ +local mason_path = vim.fn.glob(vim.fn.stdpath("data") .. "/mason/") +local codelldb_adapter = { + type = "server", + port = "${port}", + executable = { + command = mason_path .. "bin/codelldb", + args = { "--port", "${port}" }, + }, +} + +pcall(function() + require("rust-tools").setup({ + tools = { + reload_workspace_from_cargo_toml = true, + runnables = { + use_telescope = true, + }, + inlay_hints = { + auto = true, + only_current_line = false, + show_parameter_hints = false, + parameter_hints_prefix = "<-", + other_hints_prefix = "=> ", + highlight = "Comment", + }, + hover_actions = { + border = "rounded", + }, + on_initialized = function() + vim.api.nvim_create_autocmd({ "BufWritePost", "BufEnter", "CursorHold", "InsertLeave" }, { + pattern = { "*.rs" }, + callback = function() + local _, _ = pcall(vim.lsp.codelens.refresh) + end, + }) + end, + }, + dap = { + adapter = codelldb_adapter, + }, + server = { + on_attach = function(client, bufnr) + require("lvim.lsp").common_on_attach(client, bufnr) + local rt = require("rust-tools") + vim.keymap.set("n", "K", rt.hover_actions.hover_actions, { buffer = bufnr }) + end, + + capabilities = require("lvim.lsp").common_capabilities(), + settings = { + ["rust-analyzer"] = { + lens = { + enable = true, + }, + checkOnSave = { + enable = true, + command = "clippy", + }, + }, + }, + }, + }) +end) + +lvim.builtin.dap.on_config_done = function(dap) + dap.adapters.codelldb = codelldb_adapter + dap.configurations.rust = { + { + name = "Launch file", + type = "codelldb", + request = "launch", + program = function() + vim.fn.jobstart("cargo test --no-run") + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/target/debug/", "file") + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + }, + } +end + +-- vim.api.nvim_set_keymap("n", "", "RustOpenExternalDocs", { noremap = true, silent = true }) + +-- lvim.builtin.which_key.mappings["C"] = { +-- name = "Rust", +-- r = { "RustRunnables", "Runnables" }, +-- t = { "lua _CARGO_TEST()", "Cargo Test" }, +-- m = { "RustExpandMacro", "Expand Macro" }, +-- c = { "RustOpenCargo", "Open Cargo" }, +-- p = { "RustParentModule", "Parent Module" }, +-- d = { "RustDebuggables", "Debuggables" }, +-- v = { "RustViewCrateGraph", "View Crate Graph" }, +-- R = { +-- "lua require('rust-tools/workspace_refresh')._reload_workspace_from_cargo_toml()", +-- "Reload Workspace", +-- }, +-- o = { "RustOpenExternalDocs", "Open External Docs" }, +-- y = { "lua require'crates'.open_repository()", "[crates] open repository" }, +-- P = { "lua require'crates'.show_popup()", "[crates] show popup" }, +-- i = { "lua require'crates'.show_crate_popup()", "[crates] show info" }, +-- f = { "lua require'crates'.show_features_popup()", "[crates] show features" }, +-- D = { "lua require'crates'.show_dependencies_popup()", "[crates] show dependencies" }, +-- } diff --git a/dot_config/lvim/lua/hammy/packer.lua b/dot_config/lvim/lua/hammy/packer.lua new file mode 100644 index 0000000..db6c922 --- /dev/null +++ b/dot_config/lvim/lua/hammy/packer.lua @@ -0,0 +1,93 @@ +lvim.plugins = { + { "andweeb/presence.nvim" }, + { "hrsh7th/cmp-cmdline" }, + { "gpanders/editorconfig.nvim" }, + { "p00f/nvim-ts-rainbow" }, + { "nvim-treesitter/playground" }, + { "simrat39/rust-tools.nvim" }, + { + "saecki/crates.nvim", + tag = "v0.3.0", + requires = { "nvim-lua/plenary.nvim" }, + config = function() + require("crates").setup({ + null_ls = { + enabled = true, + name = "crates.nvim", + }, + popup = { + border = "rounded", + }, + }) + end, + }, + { + "axkirillov/easypick.nvim", + config = function() + local easypick = require("easypick") + easypick.setup({ + pickers = { + { + name = "chezmoi", + command = [[chezmoi managed -x encrypted -i files | awk '{ printf("%s/%s\n", "~", $0) }']], + opts = require("telescope.themes").get_dropdown({}), + }, + }, + }) + end, + }, + { + "stevearc/dressing.nvim", + config = function() + require("dressing").setup({ input = { insert_only = false } }) + end, + }, + { + "kylechui/nvim-surround", + tag = "*", -- Use for stability; omit to use `main` branch for the latest features + config = function() + require("nvim-surround").setup() + end, + }, + { + "catppuccin/nvim", + as = "catppuccin", + config = function() + local cp = require("catppuccin.palettes").get_palette() + + require("catppuccin").setup({ + flavour = "mocha", + compile_path = vim.fn.stdpath("cache") .. "/catppuccin", + transparent_background = true, + term_colors = true, + no_italic = true, + integrations = { + ts_rainbow = true, + which_key = true, + dap = { enabled = true, enable_ui = true }, + navic = { enabled = true, custom_bg = "NONE" }, + }, + color_overrides = { + mocha = { + base = "#000000", + mantle = "#000000", + surface2 = cp.subtext0, + overlay0 = cp.subtext0, + }, + }, + custom_highlights = { + ErrorMsg = { fg = cp.red, style = { "bold" } }, + LspInfoBorder = { link = "FloatBorder" }, + PmenuSel = { bg = cp.surface0 }, + FloatBorder = { fg = cp.overlay0, bg = "NONE" }, + TelescopeBorder = { link = "FloatBorder" }, + TelescopeMatching = { link = "TelescopeNormal" }, + TelescopeSelection = { fg = "NONE", bg = cp.surface0 }, + TelescopeTitle = { fg = cp.subtext0 }, + }, + }) + + vim.api.nvim_command("colorscheme catppuccin") + end, + }, +} diff --git a/dot_config/lvim/lua/hammy/plugin/cmp.lua b/dot_config/lvim/lua/hammy/plugin/cmp.lua new file mode 100644 index 0000000..a0501eb --- /dev/null +++ b/dot_config/lvim/lua/hammy/plugin/cmp.lua @@ -0,0 +1,10 @@ +local cmp = require("cmp") +local mappings = { + [""] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), +} + +lvim.builtin.cmp.cmdline.enable = true +lvim.builtin.cmp.mapping = vim.tbl_deep_extend("keep", mappings, lvim.builtin.cmp.mapping) diff --git a/dot_config/lvim/lua/hammy/plugin/dashboard.lua b/dot_config/lvim/lua/hammy/plugin/dashboard.lua new file mode 100644 index 0000000..4863b15 --- /dev/null +++ b/dot_config/lvim/lua/hammy/plugin/dashboard.lua @@ -0,0 +1,11 @@ +lvim.builtin.alpha.active = true +lvim.builtin.alpha.mode = "dashboard" + +lvim.builtin.alpha.dashboard.section.header.val = { + [[ __ ]], + [[ ___ ___ ___ __ __ /\_\ ___ ___ ]], + [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]], + [[/\ \/\ \/\ __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]], + [[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]], + [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]], +} diff --git a/dot_config/lvim/lua/hammy/plugin/init.lua b/dot_config/lvim/lua/hammy/plugin/init.lua new file mode 100644 index 0000000..0ca8f5e --- /dev/null +++ b/dot_config/lvim/lua/hammy/plugin/init.lua @@ -0,0 +1,14 @@ +require("hammy.plugin.cmp") +require("hammy.plugin.treesitter") +require("hammy.plugin.telescope") +require("hammy.plugin.dashboard") +require("hammy.plugin.nvimtree") + +-- Enable/Disable Lvim Plugins +lvim.builtin.project.active = true +lvim.builtin.bufferline.active = false +lvim.builtin.breadcrumbs.active = true +lvim.builtin.terminal.active = false +lvim.builtin.indentlines.active = false +lvim.builtin.illuminate.active = false + diff --git a/dot_config/lvim/lua/hammy/plugin/nvimtree.lua b/dot_config/lvim/lua/hammy/plugin/nvimtree.lua new file mode 100644 index 0000000..ba5fcbc --- /dev/null +++ b/dot_config/lvim/lua/hammy/plugin/nvimtree.lua @@ -0,0 +1,2 @@ +lvim.builtin.nvimtree.setup.view.side = "left" +lvim.builtin.nvimtree.setup.renderer.icons.show.git = true diff --git a/dot_config/lvim/lua/hammy/plugin/telescope.lua b/dot_config/lvim/lua/hammy/plugin/telescope.lua new file mode 100644 index 0000000..283cf6e --- /dev/null +++ b/dot_config/lvim/lua/hammy/plugin/telescope.lua @@ -0,0 +1,38 @@ +lvim.builtin.telescope.defaults.prompt_prefix = "🔍 " +lvim.builtin.telescope.defaults.selection_caret = "> " +lvim.builtin.telescope.defaults.file_ignore_patterns = { ".git/" } + +lvim.builtin.which_key.mappings["f"] = { + name = "Find", + b = { "Telescope buffers", "Open Buffers" }, + f = { "Telescope find_files", "Find File" }, + h = { "Telescope help_tags", "Find Help" }, + H = { "Telescope highlights", "Find Highlights" }, + g = { "Telescope live_grep", "Find Text" }, + R = { "Telescope registers", "Find Registers" }, + k = { "Telescope keymaps", "Find Keymaps" }, + c = { + "Telescope current_buffer_fuzzy_find", + "Find Text In Current Buffer", + }, + C = { "Telescope commands", "Find Commands" }, + r = { "Telescope oldfiles", "Open Recent File" }, + p = { "Telescope projects", "Open Projects" }, + d = { "Easypick chezmoi", "Open Dotfiles" }, +} + +local _, actions = pcall(require, "telescope.actions") +lvim.builtin.telescope.defaults.mappings = { + i = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = actions.cycle_history_next, + [""] = actions.cycle_history_prev, + }, + n = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = actions.preview_scrolling_down, + [""] = actions.preview_scrolling_up, + }, +} diff --git a/dot_config/lvim/lua/hammy/plugin/treesitter.lua b/dot_config/lvim/lua/hammy/plugin/treesitter.lua new file mode 100644 index 0000000..25c1c95 --- /dev/null +++ b/dot_config/lvim/lua/hammy/plugin/treesitter.lua @@ -0,0 +1,3 @@ +lvim.builtin.treesitter.rainbow.enable = true +lvim.builtin.treesitter.highlight.enable = true +lvim.builtin.treesitter.ensure_installed = "all" diff --git a/dot_config/lvim/lua/hammy/remap.lua b/dot_config/lvim/lua/hammy/remap.lua new file mode 100644 index 0000000..3fc6051 --- /dev/null +++ b/dot_config/lvim/lua/hammy/remap.lua @@ -0,0 +1,32 @@ +-- unmapping defaults +lvim.keys.normal_mode[""] = false +lvim.keys.normal_mode[""] = false +lvim.keys.normal_mode[""] = false +lvim.keys.insert_mode[""] = false +lvim.keys.insert_mode[""] = false +lvim.builtin.which_key.mappings["s"] = nil + +-- navigation +lvim.keys.normal_mode[""] = "j" +lvim.keys.normal_mode[""] = "k" +lvim.keys.normal_mode[""] = "l" +lvim.keys.normal_mode[""] = "h" + +-- useful +lvim.keys.normal_mode[""] = "zz" +lvim.keys.normal_mode[""] = "zz" +lvim.keys.normal_mode["J"] = "mzJ`z" +lvim.keys.normal_mode["n"] = "nzzzv" +lvim.keys.normal_mode["N"] = "Nzzzv" +lvim.keys.normal_mode[""] = "o" +lvim.keys.normal_mode["0"] = "^" +lvim.keys.normal_mode["[d"] = ":lua vim.diagnostic.goto_prev()" +lvim.keys.normal_mode["]d"] = ":lua vim.diagnostic.goto_next()" +lvim.keys.normal_mode["[c"] = ":lua require('gitsigns').prev_hunk()" +lvim.keys.normal_mode["]c"] = ":lua require('gitsigns').next_hunk()" + +-- clipboard +lvim.keys.visual_block_mode["p"] = [["_dp]] +lvim.keys.visual_mode["y"] = [["+y]] +lvim.keys.normal_mode["y"] = [["+y]] +lvim.keys.normal_mode["Y"] = [["+Y]] diff --git a/dot_config/lvim/lua/hammy/set.lua b/dot_config/lvim/lua/hammy/set.lua new file mode 100644 index 0000000..88b7879 --- /dev/null +++ b/dot_config/lvim/lua/hammy/set.lua @@ -0,0 +1,14 @@ +vim.opt.timeoutlen = 500 +vim.opt.relativenumber = true +vim.opt.laststatus = 3 +vim.opt.pumheight = 20 +vim.opt.clipboard = "" +vim.opt.lazyredraw = true +vim.opt.showtabline = 0 +vim.opt.completeopt = [[menuone,noinsert,noselect]] + +-- Lvim Related Stuffs +lvim.log.level = "warn" +lvim.format_on_save = false +lvim.colorscheme = "catppuccin" +lvim.leader = "space" diff --git a/dot_config/lvim/stylua.toml b/dot_config/lvim/stylua.toml new file mode 100644 index 0000000..cee468f --- /dev/null +++ b/dot_config/lvim/stylua.toml @@ -0,0 +1,7 @@ +column_width = 120 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferDouble" +call_parentheses = "Always" +collapse_simple_statement = "Never"