commit e53a643e3da266ced56db9174b73778c09fb33ca Author: Asep Komarudin <68836805+pojokcodeid@users.noreply.github.com> Date: Sun Jan 15 00:17:41 2023 +0700 Add files via upload diff --git a/img/Spring_boot_code.jpeg b/img/Spring_boot_code.jpeg new file mode 100644 index 0000000..b6372b7 Binary files /dev/null and b/img/Spring_boot_code.jpeg differ diff --git a/img/home.png b/img/home.png new file mode 100644 index 0000000..eb4afb3 Binary files /dev/null and b/img/home.png differ diff --git a/img/laravel.jpeg b/img/laravel.jpeg new file mode 100644 index 0000000..8966097 Binary files /dev/null and b/img/laravel.jpeg differ diff --git a/img/terminal_spring_boot.jpeg b/img/terminal_spring_boot.jpeg new file mode 100644 index 0000000..7a64760 Binary files /dev/null and b/img/terminal_spring_boot.jpeg differ diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..adc20a3 --- /dev/null +++ b/init.lua @@ -0,0 +1,16 @@ +local onsave = true +require("user.options") +require("config.lazy") +require("user.keymaps") +require("user.autocommands") +require("user.colorscheme") +require("user.snip") +if onsave then + require("user.format_onsave") +end + +-- dipindah ke plugins +-- require("user.lualine") +-- require("user.bufferline") +-- require("user.cmp") +-- require("user.lsp") diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..48a70bf --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,59 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "97a188a98b5a3a6f9b1b850799ac078faa17ab67" }, + "LuaSnip": { "branch": "master", "commit": "563827f00bb4fe43269e3be653deabc0005f1302" }, + "alpha-nvim": { "branch": "main", "commit": "0bb6fc0646bcd1cdb4639737a1cee8d6e08bcc31" }, + "bufdelete.nvim": { "branch": "master", "commit": "f79e9d186b42fba5f1b1362006e7c70240db97a4" }, + "bufferline.nvim": { "branch": "main", "commit": "83bf4dc7bff642e145c8b4547aa596803a8b4dc4" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "59224771f91b86d1de12570b4070fe4ad7cd1eeb" }, + "cmp-nvim-lua": { "branch": "main", "commit": "d276254e7198ab7d00f117e88e223b4bd8c02d21" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "code_runner.nvim": { "branch": "main", "commit": "00d3b82cc4ff0a1e0eabd09bbf125d95490d216f" }, + "dressing.nvim": { "branch": "master", "commit": "4436d6f41e2f6b8ada57588acd1a9f8b3d21453c" }, + "friendly-snippets": { "branch": "main", "commit": "7ab483b355613ef4f74189c7789278d765724d12" }, + "gitsigns.nvim": { "branch": "main", "commit": "2c6f96dda47e55fa07052ce2e2141e8367cbaaf2" }, + "impatient.nvim": { "branch": "main", "commit": "b842e16ecc1a700f62adb9802f8355b99b52a5a6" }, + "indent-blankline.nvim": { "branch": "master", "commit": "db7cbcb40cc00fc5d6074d7569fb37197705e7f6" }, + "lazy.nvim": { "branch": "main", "commit": "0d0d5870a3265f1c92a89dccef4a592c44e70179" }, + "live-server": { "branch": "main", "commit": "ecd7c1418823b65dd2bca710587c80afe42c973e" }, + "lualine.nvim": { "branch": "master", "commit": "a52f078026b27694d2290e34efa61a6e4a690621" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "43c7f402cb9822b61b5dc05bf0b385928df256a6" }, + "mason-null-ls.nvim": { "branch": "main", "commit": "07335008824788725bfa2095e18ddbb527002d63" }, + "mason.nvim": { "branch": "main", "commit": "c2002d7a6b5a72ba02388548cfaf420b864fbc12" }, + "mini.ai": { "branch": "main", "commit": "14a1382372195573c6c7f494ab8bb298b03e6f04" }, + "mini.comment": { "branch": "main", "commit": "e5294cc3e75bafb2369f235d31a98b01a9cc67ad" }, + "mini.pairs": { "branch": "main", "commit": "fec9aba50912d8c3d92d07d6a77952de84f8d7ad" }, + "mini.surround": { "branch": "main", "commit": "df41f1c009afbb3eef39d979977fb14404576f9b" }, + "neoscroll.nvim": { "branch": "master", "commit": "54c5c419f6ee2b35557b3a6a7d631724234ba97a" }, + "null-ls.nvim": { "branch": "main", "commit": "c0c19f32b614b3921e17886c541c13a72748d450" }, + "nvim-autopairs": { "branch": "master", "commit": "4fc96c8f3df89b6d23e5092d31c866c53a346347" }, + "nvim-cmp": { "branch": "main", "commit": "983453e32cb35533a119725883c04436d16c0120" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "760e27df4dd966607e8fb7fd8b6b93e3c7d2e193" }, + "nvim-lsp-installer": { "branch": "main", "commit": "17e0bfa5f2c8854d1636fcd036dc8284db136baa" }, + "nvim-lspconfig": { "branch": "master", "commit": "f11fdff7e8b5b415e5ef1837bdcdd37ea6764dda" }, + "nvim-navic": { "branch": "master", "commit": "7a2b823152fe4de65ee7925b0e32d26ed73bc57c" }, + "nvim-notify": { "branch": "master", "commit": "b005821516f1f37801a73067afd1cef2dbc4dfe8" }, + "nvim-scrollview": { "branch": "main", "commit": "ba6c48bf7919dd48a371e7b9c683b8858053e885" }, + "nvim-tree.lua": { "branch": "master", "commit": "7282f7de8aedf861fe0162a559fc2b214383c51c" }, + "nvim-treesitter": { "branch": "master", "commit": "69388e84c34d40c3d5c7d2f310db13276f2179e1" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "a8c86f48c1030acee22b9e071e3c531de77bf253" }, + "nvim-ts-autotag": { "branch": "main", "commit": "fdefe46c6807441460f11f11a167a2baf8e4534b" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "4a42b30376c1bd625ab5016c2079631d531d797a" }, + "nvim-ts-rainbow": { "branch": "master", "commit": "ef95c15a935f97c65a80e48e12fe72d49aacf9b9" }, + "nvim-web-devicons": { "branch": "master", "commit": "563f3635c2d8a7be7933b9e547f7c178ba0d4352" }, + "plenary.nvim": { "branch": "master", "commit": "4b7e52044bbb84242158d977a50c4cbcd85070c7" }, + "project.nvim": { "branch": "main", "commit": "628de7e433dd503e782831fe150bb750e56e55d6" }, + "smart-splits.nvim": { "branch": "master", "commit": "fdd158ce7554dc830fb86e0fe952cd9476cdf726" }, + "telescope.nvim": { "branch": "master", "commit": "76ea9a898d3307244dce3573392dcf2cc38f340f" }, + "todo-comments.nvim": { "branch": "main", "commit": "077c59586d9d0726b0696dc5680eb863f4e04bc5" }, + "toggleterm.nvim": { "branch": "main", "commit": "2a787c426ef00cb3488c11b14f5dcf892bbd0bda" }, + "tokyonight.nvim": { "branch": "main", "commit": "def91651c41f6d1d43ebcb50763324d35331baee" }, + "vim-bbye": { "branch": "master", "commit": "25ef93ac5a87526111f43e5110675032dbcacf56" }, + "vim-illuminate": { "branch": "master", "commit": "a2e8476af3f3e993bb0d6477438aad3096512e42" }, + "vim-startuptime": { "branch": "master", "commit": "5f52ed26e0296a3e1d1453935f417e5808eefab8" }, + "vim-visual-multi": { "branch": "master", "commit": "1c9207b28c8898ab01b54e6d6b61b0b820a814bc" }, + "which-key.nvim": { "branch": "main", "commit": "16ed12a8493628c377606da2ebac50d80736ed37" }, + "wilder.nvim": { "branch": "master", "commit": "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" }, + "yanky.nvim": { "branch": "main", "commit": "57380fe70758dae6aeac5a304a0b28b3cff3cb5c" } +} \ No newline at end of file diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..75ced55 --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,37 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + -- bootstrap lazy.nvim + -- stylua: ignore + vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath }) +end +vim.opt.rtp:prepend(vim.env.LAZY or lazypath) +vim.g.mapleader=' ' +vim.g.maplocalleader=' ' +require("lazy").setup({ + spec = { + { + import = "plugins", + }, + }, + defaults = { + lazy = true, -- every plugin is lazy-loaded by default + version = "*", -- try installing the latest stable version for plugins that support semver + }, + checker = { enabled = true }, -- automatically check for plugin updates + performance = { + rtp = { + -- disable some rtp plugins + disabled_plugins = { + "gzip", + "matchit", + "matchparen", + "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + "lazyredraw", + }, + }, + }, +}) diff --git a/lua/plugins/coding.lua b/lua/plugins/coding.lua new file mode 100644 index 0000000..39b6a93 --- /dev/null +++ b/lua/plugins/coding.lua @@ -0,0 +1,123 @@ +return { + -- snippets + { + "L3MON4D3/LuaSnip", + dependencies = { + "rafamadriz/friendly-snippets", + config = function() + require("luasnip.loaders.from_vscode").lazy_load() + end, + }, + opts = { + history = true, + delete_check_events = "TextChanged", + }, + -- stylua: ignore + keys = { + { + "", + function() + return require("luasnip").jumpable(1) and "luasnip-jump-next" or "" + end, + expr = true, silent = true, mode = "i", + }, + { "", function() require("luasnip").jump(1) end, mode = "s" }, + { "", function() require("luasnip").jump(-1) end, mode = { "i", "s" } }, + }, + }, + + -- auto completion + { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "saadparwaiz1/cmp_luasnip", + }, + }, + + -- auto pairs + { + "echasnovski/mini.pairs", + event = "VeryLazy", + config = function(_, opts) + require("mini.pairs").setup(opts) + end, + }, + + -- surround + { + "echasnovski/mini.surround", + keys = { "gz" }, + opts = { + mappings = { + add = "gza", -- Add surrounding in Normal and Visual modes + delete = "gzd", -- Delete surrounding + find = "gzf", -- Find surrounding (to the right) + find_left = "gzF", -- Find surrounding (to the left) + highlight = "gzh", -- Highlight surrounding + replace = "gzr", -- Replace surrounding + update_n_lines = "gzn", -- Update `n_lines` + }, + }, + config = function(_, opts) + -- use gz mappings instead of s to prevent conflict with leap + require("mini.surround").setup(opts) + end, + }, + + -- comments + { "JoosepAlviste/nvim-ts-context-commentstring" }, + { + "echasnovski/mini.comment", + event = "VeryLazy", + opts = { + hooks = { + pre = function() + require("ts_context_commentstring.internal").update_commentstring({}) + end, + }, + }, + config = function(_, opts) + require("mini.comment").setup(opts) + end, + }, + + -- better text-objects + { + "echasnovski/mini.ai", + keys = { + { "a", mode = { "x", "o" } }, + { "i", mode = { "x", "o" } }, + }, + dependencies = { + { + "nvim-treesitter/nvim-treesitter-textobjects", + init = function() + -- no need to load the plugin, since we only need its queries + require("lazy.core.loader").disable_rtp_plugin("nvim-treesitter-textobjects") + end, + }, + }, + opts = function() + local ai = require("mini.ai") + return { + n_lines = 500, + custom_textobjects = { + o = ai.gen_spec.treesitter({ + a = { "@block.outer", "@conditional.outer", "@loop.outer" }, + i = { "@block.inner", "@conditional.inner", "@loop.inner" }, + }, {}), + f = ai.gen_spec.treesitter({ a = "@function.outer", i = "@function.inner" }, {}), + c = ai.gen_spec.treesitter({ a = "@class.outer", i = "@class.inner" }, {}), + }, + } + end, + config = function(_, opts) + local ai = require("mini.ai") + ai.setup(opts) + end, + }, + } \ No newline at end of file diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua new file mode 100644 index 0000000..3f10500 --- /dev/null +++ b/lua/plugins/init.lua @@ -0,0 +1,278 @@ +return { + -- the colorscheme should be available when starting Neovim + { + "nvim-lua/plenary.nvim", + commit = "4b7e52044bbb84242158d977a50c4cbcd85070c7", + event = "BufWinEnter", + module = "plenary", + }, + { + "folke/tokyonight.nvim", + lazy = false, -- make sure we load this during startup if it is your main colorscheme + priority = 1000, -- make sure to load this before all the other start plugins + }, + { + "goolord/alpha-nvim", + commit = "0bb6fc0646bcd1cdb4639737a1cee8d6e08bcc31", + module = "alpha", + event = "BufWinEnter", + config = function() + require("user.alpha") + end, + }, + { + "nvim-lualine/lualine.nvim", + commit = "a52f078026b27694d2290e34efa61a6e4a690621", + require = { "kyazdani42/nvim-web-devicons", opt = true }, + event = "BufWinEnter", + opts=function() + require("user.lualine") + end, + }, + {"rafamadriz/friendly-snippets"}, + {"hrsh7th/nvim-cmp", + dependencies ="rafamadriz/friendly-snippets", + opts=function() + require("user.cmp") + end, + }, + { + "windwp/nvim-autopairs", + commit = "4fc96c8f3df89b6d23e5092d31c866c53a346347", + dependencies = "hrsh7th/nvim-cmp", + event="VeryLazy", + init = function() + require("user.autopairs") + end, + }, + { + "numToStr/Comment.nvim", + commit = "97a188a98b5a3a6f9b1b850799ac078faa17ab67", + event = "BufReadPost", + init = function() + require("user.comment") + end, + }, + -- include treesitter + require("plugins.treesitter") + ,{ + "kyazdani42/nvim-web-devicons", + commit = "563f3635c2d8a7be7933b9e547f7c178ba0d4352", + init = function() + require("user.webdevicons") + end, + }, + { + "kyazdani42/nvim-tree.lua", + commit = "7282f7de8aedf861fe0162a559fc2b214383c51c", + cmd = "NvimTreeToggle", + dependencies = "kyazdani42/nvim-web-devicons", + init = function() + require("user.nvim-tree") + end, + }, + { + "akinsho/bufferline.nvim", + commit = "83bf4dc7bff642e145c8b4547aa596803a8b4dc4", + dependencies = {"kyazdani42/nvim-web-devicons","famiu/bufdelete.nvim"}, + event = "VeryLazy", + config=function() + require("user.bufferline") + end, + }, + { "moll/vim-bbye", commit = "25ef93ac5a87526111f43e5110675032dbcacf56" }, + { + "akinsho/toggleterm.nvim", + commit = "2a787c426ef00cb3488c11b14f5dcf892bbd0bda", + cmd = "Toggleterm", + event = "BufWinEnter", + init = function() + require("user.toggleterm") + end, + }, + { "ahmedkhalf/project.nvim", commit = "628de7e433dd503e782831fe150bb750e56e55d6" }, + { + "lewis6991/impatient.nvim", + commit = "b842e16ecc1a700f62adb9802f8355b99b52a5a6", + init = function() + require("user.impatient") + end, + }, + { + "lukas-reineke/indent-blankline.nvim", + commit = "db7cbcb40cc00fc5d6074d7569fb37197705e7f6", + event = "BufRead", + init = function() + require("user.indentline") + end, + }, + { + "folke/which-key.nvim", + event = "BufWinEnter", + init = function() + require("user.whichkey") + end, + }, + -- start programming + { "hrsh7th/cmp-buffer", commit = "3022dbc9166796b644a841a02de8dd1cc1d311fa", dependencies = "hrsh7th/nvim-cmp"}, + { "hrsh7th/cmp-nvim-lua", commit = "d276254e7198ab7d00f117e88e223b4bd8c02d21", dependencies = "hrsh7th/nvim-cmp" }, + { + "neovim/nvim-lspconfig", + commit = "f11fdff7e8b5b415e5ef1837bdcdd37ea6764dda", + event = "BufWinEnter", + init = function() + require("user.lsp") + end, + }, + { + "williamboman/mason.nvim", + commit = "c2002d7a6b5a72ba02388548cfaf420b864fbc12", + cmd = { + "Mason", + "MasonInstall", + "MasonUninstall", + "MasonUninstallAll", + "MasonLog", + }, + dependencies={"williamboman/mason-lspconfig.nvim"}, + init = function() + vim.tbl_map(function(plugin) + pcall(require, plugin) + end, { "lspconfig", "null-ls" }) + end, + }, + { "jose-elias-alvarez/null-ls.nvim", commit = "c0c19f32b614b3921e17886c541c13a72748d450" }, + { "RRethy/vim-illuminate", commit = "a2e8476af3f3e993bb0d6477438aad3096512e42" }, + -- include for coding + require "plugins.coding" + + -- extra plugins + ,{ + "nvim-telescope/telescope.nvim", + commit = "76ea9a898d3307244dce3573392dcf2cc38f340f", + dependencies = { { "nvim-lua/plenary.nvim" } }, + cmd = "Telescope", + init = function() + require("user.telescope") + end, + }, + { "manzeloth/live-server", cmd={"LiveServer"} }, + { "mg979/vim-visual-multi", event = "BufWinEnter" }, + { + "windwp/nvim-ts-autotag", + dependencies = "nvim-treesitter", + init=function() + require('nvim-ts-autotag').setup() + end, + }, + { + "CRAG666/code_runner.nvim", + dependencies = "nvim-lua/plenary.nvim", + cmd = { "RunCode", "RunFile", "RunProject", "RunClose" }, + config = function() + require("user.coderunner") + end, + }, + { + "NvChad/nvim-colorizer.lua", + event = "BufWinEnter", + opts = function() + require("user.colorizer") + end, + }, + { "williamboman/nvim-lsp-installer" }, + { + "SmiteshP/nvim-navic", + dependencies = "neovim/nvim-lspconfig", + event = "BufRead", + config = function() + require("user.breadcrumb") + require("user.winbar") + end, + }, + { + "rcarriga/nvim-notify", + event = "BufRead", + config = function() + vim.notify = require("notify") + end, + }, + { + "mrjones2014/smart-splits.nvim", + event = "BufWinEnter", + config = function() + require("user.smartspit") + end, + }, + { + "jayp0521/mason-null-ls.nvim", + dependencies = "jose-elias-alvarez/null-ls.nvim", + event = "BufRead", + opts = function() + require("user.mason-null-ls") + end, + }, + { + "stevearc/dressing.nvim", + event = "BufWinEnter", + config = function() + require("user.dressing") + end, + }, + { + "folke/todo-comments.nvim", + event = "BufRead", + config = function() + require("todo-comments").setup() + end, + }, + { + "karb94/neoscroll.nvim", + event = "BufRead", + config = function() + require("user.neoscroll") + end, + }, + { + "dstein64/nvim-scrollview", + event = "BufRead", + config = function() + require("user.nvimscroll") + end, + }, + { + "gelguy/wilder.nvim", + event = "BufWinEnter", + config = function() + local wilder = require("wilder") + wilder.setup({ modes = { ":", "/", "?" } }) + wilder.set_option( + "renderer", + wilder.popupmenu_renderer({ + highlighter = wilder.basic_highlighter(), + left = { " ", wilder.popupmenu_devicons() }, + right = { " ", wilder.popupmenu_scrollbar() }, + }) + ) + end, + }, + { + "gbprod/yanky.nvim", + event = "BufRead", + config = function() + require("user.yanky") + end, + }, + { "dstein64/vim-startuptime", cmd="StartupTime" }, + { "p00f/nvim-ts-rainbow", event = "BufWinEnter", dependencies = "nvim-treesitter/nvim-treesitter" }, + { + "lewis6991/gitsigns.nvim", + commit = "2c6f96dda47e55fa07052ce2e2141e8367cbaaf2", + disable = vim.fn.executable("git") == 0, + ft = "gitcommit", + event = "VeryLazy", + config = function() + require("user.gitsigns") + end, + } +} \ No newline at end of file diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..1a0f364 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,62 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + event = "BufReadPost", + ---@type TSConfig + opts = { + sync_install = false, + highlight = { enable = true }, + autopairs = { + enable = true, + }, + indent = { enable = true, disable = { "python", "css" } }, + autotag = { enable = true }, + incremental_selection = { enable = true }, + rainbow = { + enable = true, + disable = { "html" }, + extended_mode = false, + max_file_lines = nil, + }, + context_commentstring = { + enable = true, + enable_autocmd = false, + config = { + -- Languages that have a single comment style + typescript = "// %s", + css = "/* %s */", + scss = "/* %s */", + html = "", + svelte = "", + vue = "", + json = "", + }, + }, + ensure_installed = { + "bash", + "html", + "c", + "javascript", + "json", + "lua", + "python", + "typescript", + "tsx", + "css", + "rust", + "java", + "yaml", + "markdown", + "markdown_inline", + }, + }, + ---@param opts TSConfig + config = function(plugin, opts) + if plugin.ensure_installed then + require("lazyvim.util").deprecate("treesitter.ensure_installed", "treesitter.opts.ensure_installed") + end + require("nvim-treesitter.configs").setup(opts) + end, + }, + } \ No newline at end of file diff --git a/lua/user/alpha.lua b/lua/user/alpha.lua new file mode 100644 index 0000000..8484f5d --- /dev/null +++ b/lua/user/alpha.lua @@ -0,0 +1,45 @@ +local status_ok, alpha = pcall(require, "alpha") +if not status_ok then + return +end + +local dashboard = require("alpha.themes.dashboard") +dashboard.section.header.val = { + [[ _ _ _ ]], + [[ (_) | | | | ]], + [[ _ __ ___ _ ___ | | __ ___ ___ __| | ___ ]], + [[| '_ \ / _ \| |/ _ \| |/ / / __/ _ \ / _` |/ _ \]], + [[| |_) | (_) | | (_) | < | (_| (_) | (_| | __/]], + [[| .__/ \___/| |\___/|_|\_\ \___\___/ \__,_|\___|]], + [[| | _/ | ]], + [[|_| |__/ ]], +} +dashboard.section.buttons.val = { + dashboard.button("f", " Find file", ":Telescope find_files "), + dashboard.button("e", " New file", ":ene startinsert "), + dashboard.button("p", " Find project", ":Telescope projects "), + dashboard.button("r", " Recently used files", ":Telescope oldfiles "), + dashboard.button("t", " Find text", ":Telescope live_grep "), + dashboard.button("c", " Configuration", ":e $MYVIMRC "), + dashboard.button("q", " Quit Neovim", ":qa"), +} + +local function footer() + -- NOTE: requires the fortune-mod package to work + -- local handle = io.popen("fortune") + -- local fortune = handle:read("*a") + -- handle:close() + -- return fortune + return "Pojok Code" +end + +dashboard.section.footer.val = footer() + +dashboard.section.footer.opts.hl = "Type" +dashboard.section.header.opts.hl = "Include" +dashboard.section.buttons.opts.hl = "Keyword" + +dashboard.opts.opts.noautocmd = true +-- vim.cmd([[autocmd User AlphaReady echo 'ready']]) +alpha.setup(dashboard.opts) + diff --git a/lua/user/autocommands.lua b/lua/user/autocommands.lua new file mode 100644 index 0000000..0cda114 --- /dev/null +++ b/lua/user/autocommands.lua @@ -0,0 +1,38 @@ +-- autocmd BufWinEnter * :set formatoptions-=cro +vim.cmd([[ + augroup _general_settings + autocmd! + autocmd FileType qf,help,man,lspinfo nnoremap q :close + autocmd TextYankPost * silent!lua require('vim.highlight').on_yank({higroup = 'Visual', timeout = 200}) + autocmd BufWinEnter * :set formatoptions=croql + autocmd FileType qf set nobuflisted + augroup end + + augroup _git + autocmd! + autocmd FileType gitcommit setlocal wrap + autocmd FileType gitcommit setlocal spell + augroup end + + augroup _markdown + autocmd! + autocmd FileType markdown setlocal wrap + autocmd FileType markdown setlocal spell + augroup end + + augroup _auto_resize + autocmd! + autocmd VimResized * tabdo wincmd = + augroup end + + augroup _alpha + autocmd! + autocmd User AlphaReady set showtabline=0 | autocmd BufUnload set showtabline=2 + augroup end +]]) + +-- Autoformat +-- augroup _lsp +-- autocmd! +-- autocmd BufWritePre * lua vim.lsp.buf.formatting() +-- augroup end diff --git a/lua/user/autopairs.lua b/lua/user/autopairs.lua new file mode 100644 index 0000000..d2966e6 --- /dev/null +++ b/lua/user/autopairs.lua @@ -0,0 +1,33 @@ +-- Setup nvim-cmp. +local status_ok, npairs = pcall(require, "nvim-autopairs") +if not status_ok then + return +end + +npairs.setup({ + check_ts = true, + ts_config = { + lua = { "string", "source" }, + javascript = { "string", "template_string" }, + java = false, + }, + disable_filetype = { "TelescopePrompt", "spectre_panel" }, + fast_wrap = { + map = "", + chars = { "{", "[", "(", '"', "'" }, + pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), + offset = 0, -- Offset from pattern match + end_key = "$", + keys = "qwertyuiopzxcvbnmasdfghjkl", + check_comma = true, + highlight = "PmenuSel", + highlight_grey = "LineNr", + }, +}) + +local cmp_autopairs = require("nvim-autopairs.completion.cmp") +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } })) diff --git a/lua/user/autotag.lua b/lua/user/autotag.lua new file mode 100644 index 0000000..33a92af --- /dev/null +++ b/lua/user/autotag.lua @@ -0,0 +1,10 @@ +local status_ok, cfg = pcall(require, "nvim-treesitter.configs") +if not status_ok then + return +end + +cfg.setup({ + autotag = { + enable = true, + }, +}) diff --git a/lua/user/breadcrumb.lua b/lua/user/breadcrumb.lua new file mode 100644 index 0000000..2594a81 --- /dev/null +++ b/lua/user/breadcrumb.lua @@ -0,0 +1,50 @@ +local status_ok, navic = pcall(require, "nvim-navic") +if not status_ok then + return +end + +local ico = require("user.icons") +local icons = ico.kind + +navic.setup({ + icons = { + Array = icons.Array .. " ", + Boolean = icons.Boolean, + Class = icons.Class .. " ", + Color = icons.Color .. " ", + Constant = icons.Constant .. " ", + Constructor = icons.Constructor .. " ", + Enum = icons.Enum .. " ", + EnumMember = icons.EnumMember .. " ", + Event = icons.Event .. " ", + Field = icons.Field .. " ", + File = icons.File .. " ", + Folder = icons.Folder .. " ", + Function = icons.Function .. " ", + Interface = icons.Interface .. " ", + Key = icons.Key .. " ", + Keyword = icons.Keyword .. " ", + Method = icons.Method .. " ", + Module = icons.Module .. " ", + Namespace = icons.Namespace .. " ", + Null = icons.Null .. " ", + Number = icons.Number .. " ", + Object = icons.Object .. " ", + Operator = icons.Operator .. " ", + Package = icons.Package .. " ", + Property = icons.Property .. " ", + Reference = icons.Reference .. " ", + Snippet = icons.Snippet .. " ", + String = icons.String .. " ", + Struct = icons.Struct .. " ", + Text = icons.Text .. " ", + TypeParameter = icons.TypeParameter .. " ", + Unit = icons.Unit .. " ", + Value = icons.Value .. " ", + Variable = icons.Variable .. " ", + }, + highlight = true, + separator = " " .. ico.ui.ChevronRight .. " ", + depth_limit = 0, + depth_limit_indicator = "..", +}) diff --git a/lua/user/bufferline.lua b/lua/user/bufferline.lua new file mode 100644 index 0000000..9731a56 --- /dev/null +++ b/lua/user/bufferline.lua @@ -0,0 +1,211 @@ +local status_ok, bufferline = pcall(require, "bufferline") +if not status_ok then + return +end + +local icons = require("user.icons") +local use_icons = true + +local function diagnostics_indicator(num, _, diagnostics, _) + local result = {} + local symbols = { + error = icons.diagnostics.Error, + warning = icons.diagnostics.Warning, + info = icons.diagnostics.Information, + } + if not use_icons then + return "(" .. num .. ")" + end + for name, count in pairs(diagnostics) do + if symbols[name] and count > 0 then + table.insert(result, symbols[name] .. " " .. count) + end + end + result = table.concat(result, " ") + return #result > 0 and result or "" +end + +bufferline.setup({ + options = { + color_icons = true, + numbers = "none", -- | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string, + --close_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" + close_command = function(bufnum) + require('bufdelete').bufdelete(bufnum, true) + end, + --right_mouse_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" + right_mouse_command = function(bufnum) + require('bufdelete').bufdelete(bufnum, true) + end, + left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions" + middle_mouse_command = nil, -- can be a string | function, see "Mouse actions" + -- NOTE: this plugin is designed with this icon in mind, + -- and so changing this is NOT recommended, this is intended + -- as an escape hatch for people who cannot bear it for whatever reason + indicator_icon = nil, + indicator = { style = "icon", icon = "▎" }, + --buffer_close_icon = "", + buffer_close_icon = icons.ui.Close, + -- buffer_close_icon = '', + -- modified_icon = "●", + modified_icon = icons.ui.Circle, + -- close_icon = "", + close_icon = icons.ui.BoldClose, + -- close_icon = '', + --left_trunc_marker = "", + left_trunc_marker = icons.ui.ArrowCircleLeft, + --right_trunc_marker = "", + right_trunc_marker = icons.ui.ArrowCircleRight, + --- name_formatter can be used to change the buffer's label in the bufferline. + --- Please note some names can/will break the + --- bufferline so use this at your discretion knowing that it has + --- some limitations that will *NOT* be fixed. + -- name_formatter = function(buf) -- buf contains a "name", "path" and "bufnr" + -- -- remove extension from markdown files for example + -- if buf.name:match('%.md') then + -- return vim.fn.fnamemodify(buf.name, ':t:r') + -- end + -- end, + max_name_length = 30, + max_prefix_length = 30, -- prefix used when a buffer is de-duplicated + tab_size = 21, + diagnostics = false, -- | "nvim_lsp" | "coc", + diagnostics_update_in_insert = false, + diagnostics_indicator = diagnostics_indicator, + -- diagnostics_indicator = function(count, level, diagnostics_dict, context) + -- return "("..count..")" + -- end, + -- NOTE: this will be called a lot so don't do any heavy processing here + -- custom_filter = function(buf_number) + -- -- filter out filetypes you don't want to see + -- if vim.bo[buf_number].filetype ~= "" then + -- return true + -- end + -- -- filter out by buffer name + -- if vim.fn.bufname(buf_number) ~= "" then + -- return true + -- end + -- -- filter out based on arbitrary rules + -- -- e.g. filter out vim wiki buffer from tabline in your work repo + -- if vim.fn.getcwd() == "" and vim.bo[buf_number].filetype ~= "wiki" then + -- return true + -- end + -- end, + offsets = { { + filetype = "NvimTree", + text = function() + return vim.fn.getcwd() + end, + highlight = "Directory", + text_align = "left", + padding = 1 } + }, + show_buffer_icons = true, + show_buffer_close_icons = true, + show_close_icon = true, + show_tab_indicators = true, + persist_buffer_sort = true, -- whether or not custom sorted buffers should persist + -- can also be a table containing 2 custom separators + -- [focused and unfocused]. eg: { '|', '|' } + separator_style = "thin", -- | "thick" | "thin" | { 'any', 'any' }, + enforce_regular_tabs = true, + always_show_bufferline = true, + -- sort_by = 'id' | 'extension' | 'relative_directory' | 'directory' | 'tabs' | function(buffer_a, buffer_b) + -- -- add custom logic + -- return buffer_a.modified > buffer_b.modified + -- end + }, + highlights = { + fill = { + fg = { attribute = "fg", highlight = "#ff0000" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + background = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + -- buffer_selected = { + -- fg = {attribute='fg',highlight='#ff0000'}, + -- bg = {attribute='bg',highlight='#0000ff'}, + -- gui = 'none' + -- }, + buffer_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + close_button = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + close_button_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + -- close_button_selected = { + -- fg = {attribute='fg',highlight='TabLineSel'}, + -- bg ={attribute='bg',highlight='TabLineSel'} + -- }, + + tab_selected = { + fg = { attribute = "fg", highlight = "Normal" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + tab = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + tab_close = { + -- fg = {attribute='fg',highlight='LspDiagnosticsDefaultError'}, + fg = { attribute = "fg", highlight = "TabLineSel" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + + duplicate_selected = { + fg = { attribute = "fg", highlight = "TabLineSel" }, + bg = { attribute = "bg", highlight = "TabLineSel" }, + underline = true, + }, + duplicate_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + underline = true, + }, + duplicate = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + underline = true, + }, + + modified = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + modified_selected = { + fg = { attribute = "fg", highlight = "Normal" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + modified_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + separator = { + fg = { attribute = "bg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + separator_selected = { + fg = { attribute = "bg", highlight = "Normal" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + -- separator_visible = { + -- fg = {attribute='bg',highlight='TabLine'}, + -- bg = {attribute='bg',highlight='TabLine'} + -- }, + indicator_selected = { + fg = { attribute = "fg", highlight = "LspDiagnosticsDefaultHint" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + }, +}) diff --git a/lua/user/cmp.lua b/lua/user/cmp.lua new file mode 100644 index 0000000..81c2734 --- /dev/null +++ b/lua/user/cmp.lua @@ -0,0 +1,141 @@ +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end + +local snip_status_ok, luasnip = pcall(require, "luasnip") +if not snip_status_ok then + return +end + +require("luasnip/loaders/from_vscode").lazy_load() + +local check_backspace = function() + local col = vim.fn.col(".") - 1 + return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") +end + +--   פּ ﯟ   some other good icons +-- local kind_icons = { +-- Text = "", +-- Method = "m", +-- Function = "", +-- Constructor = "", +-- Field = "", +-- Variable = "", +-- Class = "", +-- Interface = "", +-- Module = "", +-- Property = "", +-- Unit = "", +-- Value = "", +-- Enum = "", +-- Keyword = "", +-- Snippet = "", +-- Color = "", +-- File = "", +-- Reference = "", +-- Folder = "", +-- EnumMember = "", +-- Constant = "", +-- Struct = "", +-- Event = "", +-- Operator = "", +-- TypeParameter = "", +-- } +-- find more here: https://www.nerdfonts.com/cheat-sheet +local new_kind_icon = require("user.icons") + +cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) -- For `luasnip` users. + end, + }, + mapping = { + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), + [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + [""] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. + [""] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + -- Accept currently selected item. If none selected, `select` first item. + -- Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expandable() then + luasnip.expand() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif check_backspace() then + fallback() + else + fallback() + end + end, { + "i", + "s", + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { + "i", + "s", + }), + }, + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + -- Kind icons + -- vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) + vim_item.kind = string.format("%s", new_kind_icon["kind"][vim_item.kind]) + -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind + vim_item.menu = ({ + -- nvim_lsp = "[LSP]", + -- luasnip = "[Snippet]", + -- buffer = "[Buffer]", + -- path = "[Path]", + nvim_lsp = "(LSP)", + luasnip = "(Snippet)", + buffer = "(Buffer)", + path = "(Path)", + })[entry.source.name] + return vim_item + end, + }, + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + -- documentation = { + -- border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + -- }, + }, + experimental = { + ghost_text = false, + native_menu = false, + }, +}) diff --git a/lua/user/coderunner.lua b/lua/user/coderunner.lua new file mode 100644 index 0000000..3813a65 --- /dev/null +++ b/lua/user/coderunner.lua @@ -0,0 +1,24 @@ +local status_ok, code_runner = pcall(require, "code_runner") +if not status_ok then + return +end +code_runner.setup({ + -- put here the commands by filetype + filetype = { + java = "cd $dir && javac $fileName && java $fileNameWithoutExt", + python = "python3 -u", + typescript = "deno run", + javascript = "node $dir/$fileName", + rust = "cd $dir && rustc $fileName && $dir/$fileNameWithoutExt", + -- cpp="gcc $fileName -lstdc++ -o $fileNameWithoutExt && $fileNameWithoutExt" + cpp = "g++ $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt", + scss = "sass $dir/$fileName $dir/$fileNameWithoutExt.css", + }, + mode = "term", + focus = true, + startinsert = true, + term = { + position = "vert", + size = 50, + }, +}) diff --git a/lua/user/colorizer.lua b/lua/user/colorizer.lua new file mode 100644 index 0000000..318656a --- /dev/null +++ b/lua/user/colorizer.lua @@ -0,0 +1,11 @@ +local status_ok, colorizer_cfg = pcall(require, "colorizer") +if not status_ok then + return +end +colorizer_cfg.setup({ + filetypes = { + "*", -- Highlight all files, but customize some others. + css = { rgb_fn = true }, -- Enable parsing rgb(...) functions in css. + html = { names = false }, -- Disable parsing "names" like Blue or Gray + }, +}) diff --git a/lua/user/colorscheme.lua b/lua/user/colorscheme.lua new file mode 100644 index 0000000..caf9dee --- /dev/null +++ b/lua/user/colorscheme.lua @@ -0,0 +1,8 @@ +local colorscheme = "tokyonight-night" +-- local colorscheme = "nord" +-- local colorscheme = "lunar" + +local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme) +if not status_ok then + return +end diff --git a/lua/user/comment.lua b/lua/user/comment.lua new file mode 100644 index 0000000..5dd682f --- /dev/null +++ b/lua/user/comment.lua @@ -0,0 +1,32 @@ +local status_ok, comment = pcall(require, "Comment") +if not status_ok then + return +end + +comment.setup({ + pre_hook = function(ctx) + local U = require("Comment.utils") + + local status_utils_ok, utils = pcall(require, "ts_context_commentstring.utils") + if not status_utils_ok then + return + end + + local location = nil + if ctx.ctype == U.ctype.block then + location = utils.get_cursor_location() + elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then + location = utils.get_visual_start_location() + end + + local status_internals_ok, internals = pcall(require, "ts_context_commentstring.internals") + if not status_internals_ok then + return + end + + return internals.calculate_commentstring({ + key = ctx.ctype == U.ctype.line and "__default" or "__multiline", + location = location, + }) + end, +}) diff --git a/lua/user/dressing.lua b/lua/user/dressing.lua new file mode 100644 index 0000000..e0a7ae6 --- /dev/null +++ b/lua/user/dressing.lua @@ -0,0 +1,15 @@ +local status_ok, dressing = pcall(require, "dressing") +if not status_ok then + return +end + +dressing.setup({ + input = { + default_prompt = "➤ ", + win_options = { winhighlight = "Normal:Normal,NormalNC:Normal" }, + }, + select = { + backend = { "telescope", "builtin" }, + builtin = { win_options = { winhighlight = "Normal:Normal,NormalNC:Normal" } }, + }, +}) diff --git a/lua/user/format_onsave.lua b/lua/user/format_onsave.lua new file mode 100644 index 0000000..5a7c59e --- /dev/null +++ b/lua/user/format_onsave.lua @@ -0,0 +1,22 @@ +function format_filter(client) + local filetype = vim.bo.filetype + local n = require "null-ls" + local s = require "null-ls.sources" + local method = n.methods.FORMATTING + local available_formatters = s.get_available(filetype, method) + + if #available_formatters > 0 then + return client.name == "null-ls" + elseif client.supports_method "textDocument/formatting" then + return true + else + return false + end +end +vim.cmd [[ +augroup _lsp + autocmd! + " autocmd BufWritePre * lua vim.lsp.buf.format{timeout_ms =200, filter=format_filter} + autocmd BufWritePre * lua vim.lsp.buf.format{filter=format_filter} + augroup end +]] diff --git a/lua/user/functions.lua b/lua/user/functions.lua new file mode 100644 index 0000000..d68f5eb --- /dev/null +++ b/lua/user/functions.lua @@ -0,0 +1,33 @@ +local M = {} + +function M.smart_quit() + local bufnr = vim.api.nvim_get_current_buf() + local buf_windows = vim.call("win_findbuf", bufnr) + local modified = vim.api.nvim_buf_get_option(bufnr, "modified") + if modified and #buf_windows == 1 then + vim.ui.input({ + prompt = "You have unsaved changes. Quit anyway? (y/n) ", + }, function(input) + if input == "y" then + vim.cmd("q!") + end + end) + else + vim.cmd("q!") + end +end + +function M.isempty(s) + return s == nil or s == "" +end + +function M.get_buf_option(opt) + local status_ok, buf_option = pcall(vim.api.nvim_buf_get_option, 0, opt) + if not status_ok then + return nil + else + return buf_option + end +end + +return M diff --git a/lua/user/gitsigns.lua b/lua/user/gitsigns.lua new file mode 100644 index 0000000..744ecc7 --- /dev/null +++ b/lua/user/gitsigns.lua @@ -0,0 +1,48 @@ +local status_ok, gitsigns = pcall(require, "gitsigns") +if not status_ok then + return +end + +gitsigns.setup { + signs = { + add = { hl = "GitSignsAdd", text = "▎", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, + change = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + delete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + topdelete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + changedelete = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + }, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = false, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + watch_gitdir = { + interval = 1000, + follow_files = true, + }, + attach_to_untracked = true, + current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + ignore_whitespace = false, + }, + current_line_blame_formatter_opts = { + relative_time = false, + }, + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + max_file_length = 40000, + preview_config = { + -- Options passed to nvim_open_win + border = "single", + style = "minimal", + relative = "cursor", + row = 0, + col = 1, + }, + yadm = { + enable = false, + }, +} diff --git a/lua/user/icons.lua b/lua/user/icons.lua new file mode 100644 index 0000000..c72ebf6 --- /dev/null +++ b/lua/user/icons.lua @@ -0,0 +1,154 @@ +return { + kind = { + Array = "", + Boolean = "", + Class = "", + Color = "", + Constant = "", + Constructor = "", + Enum = "", + EnumMember = "", + Event = "", + Field = "", + File = "", + Folder = "", + Function = "", + Interface = "", + Key = "", + Keyword = "", + Method = "", + Module = "", + Namespace = "", + Null = "ﳠ", + Number = "", + Object = "", + Operator = "", + Package = "", + Property = "", + Reference = "", + Snippet = "", + String = "", + Struct = "", + Text = "", + TypeParameter = "", + Unit = "", + Value = "", + Variable = "", + }, + git = { + LineAdded = "", + LineModified = "", + LineRemoved = "", + FileDeleted = "", + FileIgnored = "◌", + FileRenamed = "", + FileStaged = "S", + FileUnmerged = "", + FileUnstaged = "", + FileUntracked = "U", + Diff = "", + Repo = "", + Octoface = "", + Branch = "", + }, + ui = { + ArrowCircleDown = "", + ArrowCircleLeft = "", + ArrowCircleRight = "", + ArrowCircleUp = "", + BoldArrowDown = "", + BoldArrowLeft = "", + BoldArrowRight = "", + BoldArrowUp = "", + BoldClose = "", + BoldDividerLeft = "", + BoldDividerRight = "", + BoldLineLeft = "▎", + BookMark = "", + BoxChecked = "", + Bug = "", + Stacks = "", + Scopes = "", + Watches = "", + DebugConsole = "", + Calendar = "", + Check = "", + ChevronRight = ">", + ChevronShortDown = "", + ChevronShortLeft = "", + ChevronShortRight = "", + ChevronShortUp = "", + Circle = "", + Close = "", + CloudDownload = "", + Code = "", + Comment = "", + Dashboard = "", + DividerLeft = "", + DividerRight = "", + DoubleChevronRight = "»", + Ellipsis = "", + EmptyFolder = "", + EmptyFolderOpen = "", + File = "", + FileSymlink = "", + Files = "", + FindFile = "", + FindText = "", + Fire = "", + Folder = "", + FolderOpen = "", + FolderSymlink = "", + Forward = "", + Gear = "", + History = "", + Lightbulb = "", + LineLeft = "▏", + LineMiddle = "│", + List = "", + Lock = "", + NewFile = "", + Note = "", + Package = "", + Pencil = "", + Plus = "", + Project = "", + Search = "", + SignIn = "", + SignOut = "", + Tab = "", + Table = "", + Target = "", + Telescope = "", + Text = "", + Tree = "", + Triangle = "契", + TriangleShortArrowDown = "", + TriangleShortArrowLeft = "", + TriangleShortArrowRight = "", + TriangleShortArrowUp = "", + }, + diagnostics = { + BoldError = "", + Error = "", + BoldWarning = "", + Warning = "", + BoldInformation = "", + Information = "", + BoldQuestion = "", + Question = "", + BoldHint = "", + Hint = "", + Debug = "", + Trace = "✎", + }, + misc = { + Robot = "ﮧ", + Squirrel = "", + Tag = "", + Watch = "", + Smiley = "", + Package = "", + CircuitBoard = "", + }, +} diff --git a/lua/user/impatient.lua b/lua/user/impatient.lua new file mode 100644 index 0000000..81c2356 --- /dev/null +++ b/lua/user/impatient.lua @@ -0,0 +1,6 @@ +local status_ok, impatient = pcall(require, "impatient") +if not status_ok then + return +end + +impatient.enable_profile() diff --git a/lua/user/indentline.lua b/lua/user/indentline.lua new file mode 100644 index 0000000..1199289 --- /dev/null +++ b/lua/user/indentline.lua @@ -0,0 +1,70 @@ +local status_ok, indent_blankline = pcall(require, "indent_blankline") +if not status_ok then + return +end + +vim.g.indent_blankline_buftype_exclude = { "terminal", "nofile" } +vim.g.indent_blankline_filetype_exclude = { + "help", + "startify", + "dashboard", + "packer", + "neogitstatus", + "NvimTree", + "Trouble", +} +vim.g.indentLine_enabled = 1 +-- vim.g.indent_blankline_char = "│" +vim.g.indent_blankline_char = "▏" +-- vim.g.indent_blankline_char = "▎" +vim.g.indent_blankline_show_trailing_blankline_indent = false +vim.g.indent_blankline_show_first_indent_level = true +vim.g.indent_blankline_use_treesitter = true +vim.g.indent_blankline_show_current_context = true +vim.g.indent_blankline_context_patterns = { + "class", + "return", + "function", + "method", + "^if", + "^while", + "jsx_element", + "^for", + "^object", + "^table", + "block", + "arguments", + "if_statement", + "else_clause", + "jsx_element", + "jsx_self_closing_element", + "try_statement", + "catch_clause", + "import_statement", + "operation_type", +} +-- HACK: work-around for https://github.com/lukas-reineke/indent-blankline.nvim/issues/59 +vim.wo.colorcolumn = "99999" + +-- vim.cmd [[highlight IndentBlanklineIndent1 guifg=#E06C75 gui=nocombine]] +-- vim.cmd [[highlight IndentBlanklineIndent2 guifg=#E5C07B gui=nocombine]] +-- vim.cmd [[highlight IndentBlanklineIndent3 guifg=#98C379 gui=nocombine]] +-- vim.cmd [[highlight IndentBlanklineIndent4 guifg=#56B6C2 gui=nocombine]] +-- vim.cmd [[highlight IndentBlanklineIndent5 guifg=#61AFEF gui=nocombine]] +-- vim.cmd [[highlight IndentBlanklineIndent6 guifg=#C678DD gui=nocombine]] +-- vim.opt.list = true +-- vim.opt.listchars:append "space:⋅" +-- vim.opt.listchars:append "space:" +-- vim.opt.listchars:append "eol:↴" + +indent_blankline.setup({ + -- show_end_of_line = true, + -- space_char_blankline = " ", + show_current_context = true, + -- show_current_context_start = true, + -- char_highlight_list = { + -- "IndentBlanklineIndent1", + -- "IndentBlanklineIndent2", + -- "IndentBlanklineIndent3", + -- }, +}) diff --git a/lua/user/keymaps.lua b/lua/user/keymaps.lua new file mode 100644 index 0000000..5a05026 --- /dev/null +++ b/lua/user/keymaps.lua @@ -0,0 +1,96 @@ +local opts = { noremap = true, silent = true } + +local term_opts = { silent = true } + +-- Shorten function name +local keymap = vim.api.nvim_set_keymap + +--Remap space as leader key +keymap("", "", "", opts) +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +-- Modes +-- normal_mode = "n", +-- insert_mode = "i", +-- visual_mode = "v", +-- visual_block_mode = "x", +-- term_mode = "t", +-- command_mode = "c", + +-- Normal -- +-- Better window navigation +keymap("n", "", "h", opts) +keymap("n", "", "j", opts) +keymap("n", "", "k", opts) +keymap("n", "", "l", opts) + +-- Resize with arrows +-- keymap("n", "", ":resize -2", opts) +-- keymap("n", "", ":resize +2", opts) +-- keymap("n", "", ":vertical resize -2", opts) +-- keymap("n", "", ":vertical resize +2", opts) + +-- Navigate buffers +keymap("n", "", ":bnext", opts) +keymap("n", "", ":bprevious", opts) + +-- Move text up and down +keymap("n", "", ":m .+1==gi", opts) +keymap("n", "", ":m .-2==gi", opts) + +-- Insert -- +-- Press jk fast to exit insert mode +keymap("i", "jk", "", opts) +keymap("i", "kj", "", opts) + +-- Visual -- +-- Stay in indent mode +keymap("v", "<", "", ">gv", opts) + +-- Move text up and down +keymap("v", "", ":m .+1==", opts) +keymap("v", "", ":m .-2==", opts) +keymap("v", "p", '"_dP', opts) + +-- Visual Block -- +-- Move text up and down +keymap("x", "J", ":move '>+1gv-gv", opts) +keymap("x", "K", ":move '<-2gv-gv", opts) +keymap("x", "", ":move '>+1gv-gv", opts) +keymap("x", "", ":move '>+1gv-gv", opts) +keymap("x", "", ":move '<-2gv-gv", opts) +keymap("x", "", ":move '<-2gv-gv", opts) + +keymap("n", "", "t.", opts) +keymap("i", "", "t.", opts) +keymap("n", "", "t -1", opts) +keymap("i", "", "t -1", opts) +keymap("n", "", "t.", opts) +keymap("n", "", "t -1", opts) +keymap("n", "", "m+", opts) +keymap("i", "", "m+", opts) +keymap("n", "", "m-2", opts) +keymap("i", "", "m-2", opts) +keymap("n", "", "m+", opts) +keymap("n", "", "m-2", opts) +keymap("i", "", "w", opts) +keymap("n", "", "w", opts) +keymap("i", "", "LiveServer start", opts) +keymap("n", "q", "q", opts) +keymap("x", "", ":'<,'>t'>", opts) + +-- Visual Block -- +-- Move text up and down +keymap("x", "J", ":move '>+1gv-gv", opts) +keymap("x", "K", ":move '<-2gv-gv", opts) +keymap("x", "", ":move '>+1gv-gv", opts) +keymap("x", "", ":move '<-2gv-gv", opts) + +-- Terminal -- +-- Better terminal navigation +-- keymap("t", "", "h", term_opts) +-- keymap("t", "", "j", term_opts) +-- keymap("t", "", "k", term_opts) +-- keymap("t", "", "l", term_opts) diff --git a/lua/user/lsp/config.lua b/lua/user/lsp/config.lua new file mode 100644 index 0000000..4b1da5f --- /dev/null +++ b/lua/user/lsp/config.lua @@ -0,0 +1,25 @@ +local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer") +if not status_ok then + return +end + +local lspconfig = require("lspconfig") + +-- local servers = { "jsonls", "sumneko_lua","html","cssls","tsserver"} +local servers = { "jdtls" } + +lsp_installer.setup({ + ensure_installed = servers, +}) + +for _, server in pairs(servers) do + local opts = { + on_attach = require("user.lsp.handlers").on_attach, + capabilities = require("user.lsp.handlers").capabilities, + } + local has_custom_opts, server_custom_opts = pcall(require, "user.lsp.settings." .. server) + if has_custom_opts then + opts = vim.tbl_deep_extend("force", opts, server_custom_opts) + end + lspconfig[server].setup(opts) +end diff --git a/lua/user/lsp/handlers.lua b/lua/user/lsp/handlers.lua new file mode 100644 index 0000000..9d5f48d --- /dev/null +++ b/lua/user/lsp/handlers.lua @@ -0,0 +1,106 @@ +local M = {} + +local status_cmp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") +if not status_cmp_ok then + return +end + +local icons = require("user.icons") + +M.capabilities = vim.lsp.protocol.make_client_capabilities() +M.capabilities.textDocument.completion.completionItem.snippetSupport = true +M.capabilities = cmp_nvim_lsp.default_capabilities(M.capabilities) + +M.setup = function() + local signs = { + + -- { name = "DiagnosticSignError", text = "" }, + -- { name = "DiagnosticSignWarn", text = "" }, + -- { name = "DiagnosticSignHint", text = "" }, + -- { name = "DiagnosticSignInfo", text = "" }, + { name = "DiagnosticSignError", text = icons.diagnostics.Error }, + { name = "DiagnosticSignWarn", text = icons.diagnostics.Warning }, + { name = "DiagnosticSignHint", text = icons.diagnostics.Hint }, + { name = "DiagnosticSignInfo", text = icons.diagnostics.Info }, + } + + for _, sign in ipairs(signs) do + vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) + end + + local config = { + virtual_text = false, -- disable virtual text + signs = { + active = signs, -- show signs + }, + update_in_insert = true, + underline = true, + severity_sort = true, + float = { + focusable = true, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + } + + vim.diagnostic.config(config) + + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = "rounded", + }) + + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = "rounded", + }) +end + +local function attach_navic(client, bufnr) + vim.g.navic_silence = true + local status_ok, navic = pcall(require, "nvim-navic") + if not status_ok then + return + end + navic.attach(client, bufnr) +end + +local function lsp_keymaps(bufnr) + local opts = { noremap = true, silent = true } + local keymap = vim.api.nvim_buf_set_keymap + keymap(bufnr, "n", "gD", "lua vim.lsp.buf.declaration()", opts) + keymap(bufnr, "n", "gd", "lua vim.lsp.buf.definition()", opts) + keymap(bufnr, "n", "K", "lua vim.lsp.buf.hover()", opts) + keymap(bufnr, "n", "gI", "lua vim.lsp.buf.implementation()", opts) + keymap(bufnr, "n", "gr", "lua vim.lsp.buf.references()", opts) + keymap(bufnr, "n", "gl", "lua vim.diagnostic.open_float()", opts) + keymap(bufnr, "n", "lf", "lua vim.lsp.buf.format{ async = true }", opts) + keymap(bufnr, "n", "li", "LspInfo", opts) + keymap(bufnr, "n", "lI", "LspInstallInfo", opts) + keymap(bufnr, "n", "la", "lua vim.lsp.buf.code_action()", opts) + keymap(bufnr, "n", "lj", "lua vim.diagnostic.goto_next({buffer=0})", opts) + keymap(bufnr, "n", "lk", "lua vim.diagnostic.goto_prev({buffer=0})", opts) + keymap(bufnr, "n", "lr", "lua vim.lsp.buf.rename()", opts) + keymap(bufnr, "n", "ls", "lua vim.lsp.buf.signature_help()", opts) + keymap(bufnr, "n", "lq", "lua vim.diagnostic.setloclist()", opts) +end +M.on_attach = function(client, bufnr) + attach_navic(client, bufnr) + if client.name == "tsserver" then + client.server_capabilities.documentFormattingProvider = false + end + + if client.name == "sumneko_lua" then + client.server_capabilities.documentFormattingProvider = false + end + + lsp_keymaps(bufnr) + local status_ok, illuminate = pcall(require, "illuminate") + if not status_ok then + return + end + illuminate.on_attach(client) +end + +return M diff --git a/lua/user/lsp/init.lua b/lua/user/lsp/init.lua new file mode 100644 index 0000000..04805b4 --- /dev/null +++ b/lua/user/lsp/init.lua @@ -0,0 +1,9 @@ +local status_ok, _ = pcall(require, "lspconfig") +if not status_ok then + return +end + +require "user.lsp.mason" +require "user.lsp.config" -- ini hanya untuk windows supaya jdtls jalan, kalau pakai linu x remark saja +require("user.lsp.handlers").setup() +require "user.lsp.null-ls" diff --git a/lua/user/lsp/mason.lua b/lua/user/lsp/mason.lua new file mode 100644 index 0000000..d472748 --- /dev/null +++ b/lua/user/lsp/mason.lua @@ -0,0 +1,56 @@ +local servers = { + "sumneko_lua", + "cssls", + "html", + "tsserver", + "pyright", + -- "bashls", + "jsonls", + -- "yamlls", + -- "jdtls", + "emmet_ls", + "intelephense", + "marksman", +} + +local settings = { + ui = { + border = "none", + icons = { + package_installed = "◍", + package_pending = "◍", + package_uninstalled = "◍", + }, + }, + log_level = vim.log.levels.INFO, + max_concurrent_installers = 4, +} + +require("mason").setup(settings) +require("mason-lspconfig").setup({ + ensure_installed = servers, + automatic_installation = true, +}) + +local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig") +if not lspconfig_status_ok then + return +end + +local opts = {} + +for _, server in pairs(servers) do + opts = { + on_attach = require("user.lsp.handlers").on_attach, + capabilities = require("user.lsp.handlers").capabilities, + } + + server = vim.split(server, "@")[1] + + local require_ok, conf_opts = pcall(require, "user.lsp.settings." .. server) + if require_ok then + opts = vim.tbl_deep_extend("force", conf_opts, opts) + end + + lspconfig[server].setup(opts) +end diff --git a/lua/user/lsp/null-ls.lua b/lua/user/lsp/null-ls.lua new file mode 100644 index 0000000..7b4542a --- /dev/null +++ b/lua/user/lsp/null-ls.lua @@ -0,0 +1,44 @@ +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 + +local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + +null_ls.setup({ + debug = false, + sources = { + --formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }), + formatting.prettier, + formatting.prettierd, + formatting.black.with({ extra_args = { "--fast" } }), + formatting.stylua, + formatting.eslint_d, + formatting.google_java_format, + formatting.phpcbf, + -- formatting.clang_format, + -- diagnostics.flake8 + }, + + on_attach = function(client, bufnr) + --if client.resolved_capabilities.document_formatting then + --vim.cmd("autocmd BufWritePre lua vim.lsp.buf.format{async=true}") + --end + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format({ bufnr = bufnr }) + -- vim.lsp.buf.formatting_sync() + end, + }) + end + end, +}) diff --git a/lua/user/lsp/settings/jsonls.lua b/lua/user/lsp/settings/jsonls.lua new file mode 100644 index 0000000..b711932 --- /dev/null +++ b/lua/user/lsp/settings/jsonls.lua @@ -0,0 +1,197 @@ +local default_schemas = nil +local status_ok, jsonls_settings = pcall(require, "nlspsettings.jsonls") +if status_ok then + default_schemas = jsonls_settings.get_default_schemas() +end + +local schemas = { + { + description = "TypeScript compiler configuration file", + fileMatch = { + "tsconfig.json", + "tsconfig.*.json", + }, + url = "https://json.schemastore.org/tsconfig.json", + }, + { + description = "Lerna config", + fileMatch = { "lerna.json" }, + url = "https://json.schemastore.org/lerna.json", + }, + { + description = "Babel configuration", + fileMatch = { + ".babelrc.json", + ".babelrc", + "babel.config.json", + }, + url = "https://json.schemastore.org/babelrc.json", + }, + { + description = "ESLint config", + fileMatch = { + ".eslintrc.json", + ".eslintrc", + }, + url = "https://json.schemastore.org/eslintrc.json", + }, + { + description = "Bucklescript config", + fileMatch = { "bsconfig.json" }, + url = "https://raw.githubusercontent.com/rescript-lang/rescript-compiler/8.2.0/docs/docson/build-schema.json", + }, + { + description = "Prettier config", + fileMatch = { + ".prettierrc", + ".prettierrc.json", + "prettier.config.json", + }, + url = "https://json.schemastore.org/prettierrc", + }, + { + description = "Vercel Now config", + fileMatch = { "now.json" }, + url = "https://json.schemastore.org/now", + }, + { + description = "Stylelint config", + fileMatch = { + ".stylelintrc", + ".stylelintrc.json", + "stylelint.config.json", + }, + url = "https://json.schemastore.org/stylelintrc", + }, + { + description = "A JSON schema for the ASP.NET LaunchSettings.json files", + fileMatch = { "launchsettings.json" }, + url = "https://json.schemastore.org/launchsettings.json", + }, + { + description = "Schema for CMake Presets", + fileMatch = { + "CMakePresets.json", + "CMakeUserPresets.json", + }, + url = "https://raw.githubusercontent.com/Kitware/CMake/master/Help/manual/presets/schema.json", + }, + { + description = "Configuration file as an alternative for configuring your repository in the settings page.", + fileMatch = { + ".codeclimate.json", + }, + url = "https://json.schemastore.org/codeclimate.json", + }, + { + description = "LLVM compilation database", + fileMatch = { + "compile_commands.json", + }, + url = "https://json.schemastore.org/compile-commands.json", + }, + { + description = "Config file for Command Task Runner", + fileMatch = { + "commands.json", + }, + url = "https://json.schemastore.org/commands.json", + }, + { + description = "AWS CloudFormation provides a common language for you to describe and provision all the infrastructure resources in your cloud environment.", + fileMatch = { + "*.cf.json", + "cloudformation.json", + }, + url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/cloudformation.schema.json", + }, + { + description = "The AWS Serverless Application Model (AWS SAM, previously known as Project Flourish) extends AWS CloudFormation to provide a simplified way of defining the Amazon API Gateway APIs, AWS Lambda functions, and Amazon DynamoDB tables needed by your serverless application.", + fileMatch = { + "serverless.template", + "*.sam.json", + "sam.json", + }, + url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/sam.schema.json", + }, + { + description = "Json schema for properties json file for a GitHub Workflow template", + fileMatch = { + ".github/workflow-templates/**.properties.json", + }, + url = "https://json.schemastore.org/github-workflow-template-properties.json", + }, + { + description = "golangci-lint configuration file", + fileMatch = { + ".golangci.toml", + ".golangci.json", + }, + url = "https://json.schemastore.org/golangci-lint.json", + }, + { + description = "JSON schema for the JSON Feed format", + fileMatch = { + "feed.json", + }, + url = "https://json.schemastore.org/feed.json", + versions = { + ["1"] = "https://json.schemastore.org/feed-1.json", + ["1.1"] = "https://json.schemastore.org/feed.json", + }, + }, + { + description = "Packer template JSON configuration", + fileMatch = { + "packer.json", + }, + url = "https://json.schemastore.org/packer.json", + }, + { + description = "NPM configuration file", + fileMatch = { + "package.json", + }, + url = "https://json.schemastore.org/package.json", + }, + { + description = "JSON schema for Visual Studio component configuration files", + fileMatch = { + "*.vsconfig", + }, + url = "https://json.schemastore.org/vsconfig.json", + }, + { + description = "Resume json", + fileMatch = { "resume.json" }, + url = "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json", + }, +} + +local function extend(tab1, tab2) + for _, value in ipairs(tab2 or {}) do + table.insert(tab1, value) + end + return tab1 +end + +local extended_schemas = extend(schemas, default_schemas) + +local opts = { + settings = { + json = { + schemas = extended_schemas, + }, + }, + setup = { + commands = { + Format = { + function() + vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 }) + end, + }, + }, + }, +} + +return opts diff --git a/lua/user/lsp/settings/pyright.lua b/lua/user/lsp/settings/pyright.lua new file mode 100644 index 0000000..94b4419 --- /dev/null +++ b/lua/user/lsp/settings/pyright.lua @@ -0,0 +1,9 @@ +return { + settings = { + python = { + analysis = { + typeCheckingMode = "off", + }, + }, + }, +} diff --git a/lua/user/lsp/settings/sumneko_lua.lua b/lua/user/lsp/settings/sumneko_lua.lua new file mode 100644 index 0000000..2c078f3 --- /dev/null +++ b/lua/user/lsp/settings/sumneko_lua.lua @@ -0,0 +1,16 @@ +return { + settings = { + + Lua = { + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.stdpath("config") .. "/lua"] = true, + }, + }, + }, + }, +} diff --git a/lua/user/lualine.lua b/lua/user/lualine.lua new file mode 100644 index 0000000..44ad9e1 --- /dev/null +++ b/lua/user/lualine.lua @@ -0,0 +1,163 @@ +local status_ok, lualine = pcall(require, "lualine") +if not status_ok then + return +end +local icons = require("user.icons") +local hide_in_width = function() + return vim.fn.winwidth(0) > 80 +end + +local conditions = { + buffer_not_empty = function() + return vim.fn.empty(vim.fn.expand("%:t")) ~= 1 + end, + hide_in_width = function() + return vim.fn.winwidth(0) > 80 + end, + check_git_workspace = function() + local filepath = vim.fn.expand("%:p:h") + local gitdir = vim.fn.finddir(".git", filepath .. ";") + return gitdir and #gitdir > 0 and #gitdir < #filepath + end, +} + +local diagnostics = { + "diagnostics", + sources = { "nvim_diagnostic" }, + sections = { "error", "warn" }, + -- symbols = { error = " ", warn = " " }, + symbols = { + error = icons.diagnostics.BoldError .. " ", + warn = icons.diagnostics.BoldWarning .. " ", + }, + colored = true, + update_in_insert = false, + always_visible = false, +} + +local diff = { + "diff", + colored = true, + -- symbols = { added = " ", modified = " ", removed = " " }, -- changes diff symbols + symbols = { + added = icons.git.LineAdded .. " ", + modified = icons.git.LineModified .. " ", + removed = icons.git.LineRemoved .. " ", + }, -- changes diff symbols + cond = hide_in_width, +} + +local mode = { + "mode", + fmt = function(str) + return "-- " .. str .. " --" + end, +} + +local filetype = { + "filetype", + icons_enabled = true, + icon = nil, +} + +local branch = { + "branch", + icons_enabled = true, + --icon = "", + icon = icons.git.Branch, +} + +local location = { + "location", + padding = 0, +} + +-- cool function for progress +local progress = function() + local current_line = vim.fn.line(".") + local total_lines = vim.fn.line("$") + local chars = { "__", "▁▁", "▂▂", "▃▃", "▄▄", "▅▅", "▆▆", "▇▇", "██" } + local line_ratio = current_line / total_lines + local index = math.ceil(line_ratio * #chars) + return chars[index] +end + +local spaces = function() + -- return "->| " .. vim.api.nvim_buf_get_option(0, "shiftwidth") + return icons.ui.Tab .. " " .. vim.api.nvim_buf_get_option(0, "shiftwidth") +end + +local file_name = { + "filename", + cond = conditions.buffer_not_empty, +} + +local lsp_info = { + function() + --local msg = "No Active Lsp" + local msg = "LS Inactive" + local buf_ft = vim.api.nvim_buf_get_option(0, "filetype") + local clients = vim.lsp.get_active_clients() + if next(clients) == nil then + for i, name in ipairs(clients) do + msg = msg .. " " .. name + end + return msg + end + for _, client in ipairs(clients) do + local filetypes = client.config.filetypes + if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then + if msg == "LS Inactive" then + msg = "" + msg = msg .. client.name + else + msg = msg .. ", " .. client.name + end + end + end + return msg + end, + --icon = " ", + icon = icons.ui.Gear .. "", +} + +lualine.setup({ + options = { + icons_enabled = true, + theme = "auto", + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + disabled_filetypes = { + "TelescopePrompt", + "packer", + "alpha", + "dashboard", + "NvimTree", + "Outline", + "DressingInput", + "toggleterm", + "lazy", + }, + always_divide_middle = true, + }, + sections = { + lualine_a = { branch }, + lualine_b = { mode }, + lualine_c = { diagnostics, lsp_info }, + -- lualine_c = { file_name, lsp_info }, + -- lualine_x = { "encoding", "fileformat", "filetype" }, + lualine_x = { diff, spaces, "encoding", filetype }, + lualine_y = { location }, + lualine_z = { progress }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { "filename" }, + lualine_x = { "location" }, + lualine_y = {}, + lualine_z = {}, + }, + tabline = {}, + extensions = {}, +}) diff --git a/lua/user/mason-null-ls.lua b/lua/user/mason-null-ls.lua new file mode 100644 index 0000000..86412f0 --- /dev/null +++ b/lua/user/mason-null-ls.lua @@ -0,0 +1,6 @@ +local status_ok, mason_null_ls = pcall(require, "mason-null-ls") +if not status_ok then + return +end +mason_null_ls.setup({ automatic_setup = true }) +mason_null_ls.setup_handlers({}) diff --git a/lua/user/neoscroll.lua b/lua/user/neoscroll.lua new file mode 100644 index 0000000..092bb76 --- /dev/null +++ b/lua/user/neoscroll.lua @@ -0,0 +1,5 @@ +local status_ok, neoscroll = pcall(require, "neoscroll") +if not status_ok then + return +end +neoscroll.setup() \ No newline at end of file diff --git a/lua/user/nvim-tree.lua b/lua/user/nvim-tree.lua new file mode 100644 index 0000000..6e5cba1 --- /dev/null +++ b/lua/user/nvim-tree.lua @@ -0,0 +1,87 @@ +local status_ok, nvim_tree = pcall(require, "nvim-tree") +if not status_ok then + return +end + +local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") +if not config_status_ok then + return +end + +local tree_cb = nvim_tree_config.nvim_tree_callback +local icons = require("user.icons") + +nvim_tree.setup({ + update_focused_file = { + enable = true, + update_cwd = true, + }, + renderer = { + root_folder_modifier = ":t", + indent_markers = { + enable = true, + inline_arrows = true, + icons = { + corner = "└", + edge = "│", + item = "│", + bottom = "─", + none = " ", + }, + }, + icons = { + webdev_colors = true, + show = { + git = true, + folder = true, + file = true, + folder_arrow = true, + }, + glyphs = { + default = icons.ui.Text, + symlink = icons.ui.FileSymlink, + folder = { + arrow_open = icons.ui.ChevronShortDown, + arrow_closed = icons.ui.ChevronShortRight, + default = icons.ui.Folder, + empty = icons.ui.EmptyFolder, + empty_open = icons.ui.EmptyFolderOpen, + open = icons.ui.FolderOpen, + symlink = icons.ui.FolderSymlink, + symlink_open = icons.ui.FolderSymlink, + }, + git = { + deleted = icons.git.FileDeleted, + ignored = icons.git.FileIgnored, + renamed = icons.git.FileRenamed, + staged = icons.git.FileStaged, + unmerged = icons.git.FileUnmerged, + unstaged = icons.git.FileUnstaged, + untracked = icons.git.FileUntracked, + }, + }, + }, + }, + diagnostics = { + enable = true, + show_on_dirs = true, + icons = { + hint = icons.diagnostics.BoldHint, + info = icons.diagnostics.BoldInformation, + warning = icons.diagnostics.BoldWarning, + error = icons.diagnostics.BoldError, + }, + }, + view = { + width = 30, + hide_root_folder = true, + side = "left", + mappings = { + list = { + { key = { "l", "", "o" }, cb = tree_cb("edit") }, + { key = "h", cb = tree_cb("close_node") }, + { key = "v", cb = tree_cb("vsplit") }, + }, + }, + }, +}) diff --git a/lua/user/nvimscroll.lua b/lua/user/nvimscroll.lua new file mode 100644 index 0000000..44223c7 --- /dev/null +++ b/lua/user/nvimscroll.lua @@ -0,0 +1,9 @@ +local status_ok, scrollview = pcall(require, "scrollview") +if not status_ok then + return +end +scrollview.setup({ + bg = "LightCyan", + ctermbg = 160, +}) +vim.g.scrollview_excluded_filetypes = { "NvimTree", "vista_kind" } diff --git a/lua/user/options.lua b/lua/user/options.lua new file mode 100644 index 0000000..57d7211 --- /dev/null +++ b/lua/user/options.lua @@ -0,0 +1,55 @@ +local options = { + backspace = vim.opt.backspace + { "nostop" }, -- Don't stop backspace at insert + clipboard = "unnamedplus", -- Connection to the system clipboard + cmdheight = 0, -- hide command line unless needed + completeopt = { "menuone", "noselect" }, -- Options for insert mode completion + copyindent = true, -- Copy the previous indentation on autoindenting + cursorline = true, -- Highlight the text line of the cursor + expandtab = true, -- Enable the use of space in tab + fileencoding = "utf-8", -- File content encoding for the buffer + fillchars = { eob = " " }, -- Disable `~` on nonexistent lines + history = 100, -- Number of commands to remember in a history table + ignorecase = true, -- Case insensitive searching + laststatus = 3, -- globalstatus + lazyredraw = true, -- lazily redraw screen + mouse = "a", -- Enable mouse support + number = true, -- Show numberline + preserveindent = true, -- Preserve indent structure as much as possible + pumheight = 10, -- Height of the pop up menu + relativenumber = true, -- Show relative numberline + scrolloff = 8, -- Number of lines to keep above and below the cursor + shiftwidth = 2, -- Number of space inserted for indentation + showmode = false, -- Disable showing modes in command line + showtabline = 2, -- always display tabline + sidescrolloff = 8, -- Number of columns to keep at the sides of the cursor + signcolumn = "yes", -- Always show the sign column + smartcase = true, -- Case sensitivie searching + splitbelow = true, -- Splitting a new window below the current one + splitright = true, -- Splitting a new window at the right of the current one + swapfile = false, -- Disable use of swapfile for the buffer + tabstop = 2, -- Number of space in a tab + termguicolors = true, -- Enable 24-bit RGB color in the TUI + timeoutlen = 300, -- Length of time to wait for a mapped sequence + undofile = true, -- Enable persistent undo + updatetime = 300, -- Length of time to wait before triggering the plugin + wrap = true, -- Disable wrapping of lines longer than the width of window + writebackup = false, -- Disable making a backup before overwriting a file + -- minimal number of screen columns either side of cursor if wrap is `false` + -- guifont = "monospace:h17", -- the font used in graphical neovim applications + -- guifont = "Source_Code_Pro:h17", -- the font used in graphical neovim applications + guifont = "Hack_Nerd_Font:h17", -- the font used in graphical neovim applications + whichwrap = "bs<>[]hl", -- which "horizontal" keys are allowed to travel to prev/next line -- which "horizontal" keys are allowed to travel to prev/next line +} + +for k, v in pairs(options) do + vim.opt[k] = v +end + +-- vim.opt.shortmess = "ilmnrx" -- flags to shorten vim messages, see :help 'shortmess' +-- vim.o.winbar = "%{%v:lua.require'nvim-navic'.get_location()%}" +vim.opt.shortmess:append("c") -- don't give |ins-completion-menu| messages +vim.opt.iskeyword:append("-") -- hyphenated words recognized by searches +vim.opt.formatoptions:remove({ "t", "c", "q", "j" }) +vim.opt.formatoptions = "croql" +-- vim.opt.formatoptions:remove({ "c", "r", "o" }) -- don't insert the current comment leader automatically for auto-wrapping comments using 'textwidth', hitting in insert mode, or hitting 'o' or 'O' in normal mode. +vim.opt.runtimepath:remove("/usr/share/vim/vimfiles") -- separate vim plugins from neovim in case vim still in use diff --git a/lua/user/plugins.lua b/lua/user/plugins.lua new file mode 100644 index 0000000..cfa7a14 --- /dev/null +++ b/lua/user/plugins.lua @@ -0,0 +1,396 @@ +local fn = vim.fn + +-- Automatically install packer +local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" +if fn.empty(fn.glob(install_path)) > 0 then + PACKER_BOOTSTRAP = fn.system({ + "git", + "clone", + "--depth", + "1", + "https://github.com/wbthomason/packer.nvim", + install_path, + }) + print("Installing packer close and reopen Neovim...") + vim.cmd([[packadd packer.nvim]]) +end + +-- Autocommand that reloads neovim whenever you save the plugins.lua file +vim.cmd([[ + augroup packer_user_config + autocmd! + autocmd BufWritePost plugins.lua source | PackerSync + augroup end +]]) + +-- Use a protected call so we don't error out on first use +local status_ok, packer = pcall(require, "packer") +if not status_ok then + return +end + +-- Have packer use a popup window +packer.init({ + display = { + open_fn = function() + return require("packer.util").float({ border = "rounded" }) + end, + }, +}) + +-- Install your plugins here +return packer.startup(function(use) + use({ + "wbthomason/packer.nvim", + commit = "6afb67460283f0e990d35d229fd38fdc04063e0a", + -- config = function() + -- require("user.plugins") + -- end, + }) -- Have packer manage itself + use({ + "nvim-lua/plenary.nvim", + commit = "4b7e52044bbb84242158d977a50c4cbcd85070c7", + event = "BufWinEnter", + module = "plenary", + }) -- Useful lua functions used by lots of plugins + use({ + "windwp/nvim-autopairs", + commit = "4fc96c8f3df89b6d23e5092d31c866c53a346347", + after = "nvim-cmp", + config = function() + require("user.autopairs") + end, + }) -- Autopairs, integrates with both cmp and treesitter + use({ + "numToStr/Comment.nvim", + commit = "97a188a98b5a3a6f9b1b850799ac078faa17ab67", + event = "BufReadPost", + config = function() + require("user.comment") + end, + }) + use({ + "JoosepAlviste/nvim-ts-context-commentstring", + commit = "4d3a68c41a53add8804f471fcc49bb398fe8de08", + event = "BufReadPost", + after = "nvim-treesitter", + }) + use({ + "kyazdani42/nvim-web-devicons", + commit = "563f3635c2d8a7be7933b9e547f7c178ba0d4352", + module = "nvim-web-devicons", + config = function() + require("user.webdevicons") + end, + }) + use({ + "kyazdani42/nvim-tree.lua", + commit = "7282f7de8aedf861fe0162a559fc2b214383c51c", + -- ini dirimak karena jadi tab tidak kebuka full + -- on = { "NvimTreeToggle" }, + -- cmd = "NvimTreeToggle", + require = "kyazdani42/nvim-web-devicons", + config = function() + require("user.nvim-tree") + end, + }) + use({ + "akinsho/bufferline.nvim", + commit = "83bf4dc7bff642e145c8b4547aa596803a8b4dc4", + require = "kyazdani42/nvim-web-devicons", + event = "BufWinEnter", + config = function() + require("user.bufferline") + end, + }) + use({ "moll/vim-bbye", commit = "25ef93ac5a87526111f43e5110675032dbcacf56" }) + use({ + "nvim-lualine/lualine.nvim", + commit = "a52f078026b27694d2290e34efa61a6e4a690621", + require = { "kyazdani42/nvim-web-devicons", opt = true }, + event = "BufWinEnter", + config = function() + require("user.lualine") + end, + }) + use({ + "akinsho/toggleterm.nvim", + commit = "2a787c426ef00cb3488c11b14f5dcf892bbd0bda", + module = "toggleterm", + cmd = "Toggleterm", + event = "BufWinEnter", + config = function() + require("user.toggleterm") + end, + }) + use({ "ahmedkhalf/project.nvim", commit = "628de7e433dd503e782831fe150bb750e56e55d6" }) + use({ + "lewis6991/impatient.nvim", + commit = "b842e16ecc1a700f62adb9802f8355b99b52a5a6", + config = function() + require("user.impatient") + end, + }) + use({ + "lukas-reineke/indent-blankline.nvim", + commit = "db7cbcb40cc00fc5d6074d7569fb37197705e7f6", + event = "BufRead", + config = function() + require("user.indentline") + end, + }) + use({ + "goolord/alpha-nvim", + commit = "0bb6fc0646bcd1cdb4639737a1cee8d6e08bcc31", + module = "alpha", + event = "BufWinEnter", + config = function() + require("user.alpha") + end, + }) + use({ + "folke/which-key.nvim", + event = "BufWinEnter", + config = function() + require("user.whichkey") + end, + }) + + -- Colorschemes + use({ + "folke/tokyonight.nvim", + commit = "66bfc2e8f754869c7b651f3f47a2ee56ae557764", + -- ini diremark karena tab diatas jadi tidak ada warnanya + -- event = "BufWinEnter", + config = function() + require("user.tokyonight") + -- require("user.colorscheme") + end, + }) + + -- Cmp + use({ + "hrsh7th/nvim-cmp", + commit = "b0dff0ec4f2748626aae13f011d1a47071fe9abc", + event = "BufWinEnter", + config = function() + require("user.cmp") + end, + }) -- The completion plugin + use({ "hrsh7th/cmp-buffer", commit = "3022dbc9166796b644a841a02de8dd1cc1d311fa", after = "nvim-cmp" }) -- buffer completions + use({ "hrsh7th/cmp-path", commit = "447c87cdd6e6d6a1d2488b1d43108bfa217f56e1", after = "nvim-cmp" }) -- path completions + use({ "saadparwaiz1/cmp_luasnip", commit = "a9de941bcbda508d0a45d28ae366bb3f08db2e36", after = "nvim-cmp" }) -- snippet completions + use({ + "hrsh7th/cmp-nvim-lsp", + commit = "3cf38d9c957e95c397b66f91967758b31be4abe6", + after = "nvim-cmp", + event = "BufWinEnter", + }) + use({ "hrsh7th/cmp-nvim-lua", commit = "d276254e7198ab7d00f117e88e223b4bd8c02d21", after = "nvim-cmp" }) + + -- Snippets + use({ + "L3MON4D3/LuaSnip", + commit = "8f8d493e7836f2697df878ef9c128337cbf2bb84", + module = "luasnip", + wants = "friendly-snippets", + config = function() + require("user.snip") + end, + }) --snippet engine + use({ "rafamadriz/friendly-snippets", commit = "2be79d8a9b03d4175ba6b3d14b082680de1b31b1", opt = true }) -- a bunch of snippets to use + + -- LSP + use({ + "neovim/nvim-lspconfig", + commit = "f11fdff7e8b5b415e5ef1837bdcdd37ea6764dda", + module = "lspconfig", + event = "BufWinEnter", + config = function() + require("user.lsp") + end, + }) -- enable LSP + use({ + "williamboman/mason.nvim", + commit = "c2002d7a6b5a72ba02388548cfaf420b864fbc12", + module = "mason", + cmd = { + "Mason", + "MasonInstall", + "MasonUninstall", + "MasonUninstallAll", + "MasonLog", + }, + config = function() + vim.tbl_map(function(plugin) + pcall(require, plugin) + end, { "lspconfig", "null-ls" }) + end, + }) -- simple to use language server installer + use({ "williamboman/mason-lspconfig.nvim", commit = "0051870dd728f4988110a1b2d47f4a4510213e31" }) + use({ "jose-elias-alvarez/null-ls.nvim", commit = "c0c19f32b614b3921e17886c541c13a72748d450" }) -- for formatters and linters + use({ "RRethy/vim-illuminate", commit = "a2e8476af3f3e993bb0d6477438aad3096512e42" }) + + -- Telescope + use({ + "nvim-telescope/telescope.nvim", + commit = "76ea9a898d3307244dce3573392dcf2cc38f340f", + require = { { "nvim-lua/plenary.nvim" } }, + cmd = "Telescope", + config = function() + require("user.telescope") + end, + }) + + -- Treesitter + use({ + "nvim-treesitter/nvim-treesitter", + commit = "8e763332b7bf7b3a426fd8707b7f5aa85823a5ac", + run = ":TSUpdate", + event = "BufWinEnter", + config = function() + require("user.treesitter") + end, + }) + + -- custom akn + use({ "manzeloth/live-server" }) + use({ "mg979/vim-visual-multi", event = "BufWinEnter" }) + use({ + "windwp/nvim-ts-autotag", + event = "InsertEnter", + after = "nvim-treesitter", + -- config dipindah ke treesitter config + -- config = function() + -- require("user.autotag") + -- end, + }) + use({ + "CRAG666/code_runner.nvim", + requires = "nvim-lua/plenary.nvim", + cmd = { "RunCode", "RunFile", "RunProject", "RunClose" }, + config = function() + require("user.coderunner") + end, + }) + use({ + "NvChad/nvim-colorizer.lua", + event = "BufWinEnter", + config = function() + require("user.colorizer") + end, + }) + use({ "williamboman/nvim-lsp-installer" }) + use({ + "SmiteshP/nvim-navic", + requires = "neovim/nvim-lspconfig", + event = "BufRead", + config = function() + require("user.breadcrumb") + require("user.winbar") + end, + }) + use({ + "rcarriga/nvim-notify", + module = "notify", + event = "BufRead", + config = function() + vim.notify = require("notify") + end, + }) + use({ + "mrjones2014/smart-splits.nvim", + event = "BufWinEnter", + config = function() + require("user.smartspit") + end, + }) + -- null-ls manager + use({ + "jayp0521/mason-null-ls.nvim", + after = "null-ls.nvim", + event = "BufRead", + config = function() + require("user.mason-null-ls") + end, + }) + use({ + "stevearc/dressing.nvim", + event = "BufWinEnter", + config = function() + require("user.dressing") + end, + }) + + use({ + "folke/todo-comments.nvim", + event = "BufRead", + config = function() + require("todo-comments").setup() + end, + }) + use({ + "karb94/neoscroll.nvim", + event = "BufRead", + config = function() + require("user.neoscroll") + end, + }) + use({ + "dstein64/nvim-scrollview", + event = "BufRead", + config = function() + require("user.nvimscroll") + end, + }) + use({ + "gelguy/wilder.nvim", + event = "BufWinEnter", + config = function() + local wilder = require("wilder") + wilder.setup({ modes = { ":", "/", "?" } }) + wilder.set_option( + "renderer", + wilder.popupmenu_renderer({ + highlighter = wilder.basic_highlighter(), + left = { " ", wilder.popupmenu_devicons() }, + right = { " ", wilder.popupmenu_scrollbar() }, + }) + ) + end, + }) + use({ + "gbprod/yanky.nvim", + event = "BufRead", + config = function() + require("user.yanky") + end, + }) + use({ "dstein64/vim-startuptime" }) + use({ "p00f/nvim-ts-rainbow", event = "BufWinEnter", after = "nvim-treesitter" }) + + -- ini plugins alternatif yang tidak digunakan lagi + -- use({ "rebelot/kanagawa.nvim" }) + -- use({ "mfussenegger/nvim-jdtls" }) + -- use({ "ellisonleao/gruvbox.nvim" }) + -- use({ "EdenEast/nightfox.nvim" }) + -- use({ "morhetz/gruvbox" }) + + -- Git + use({ + "lewis6991/gitsigns.nvim", + commit = "2c6f96dda47e55fa07052ce2e2141e8367cbaaf2", + disable = vim.fn.executable("git") == 0, + ft = "gitcommit", + event = "BufWinEnter", + config = function() + require("user.gitsigns") + end, + }) + + -- Automatically set up your configuration after cloning packer.nvim + -- Put this at the end after all plugins + if PACKER_BOOTSTRAP then + require("packer").sync() + end +end) diff --git a/lua/user/project.lua b/lua/user/project.lua new file mode 100644 index 0000000..e44dd0e --- /dev/null +++ b/lua/user/project.lua @@ -0,0 +1,48 @@ +local status_ok, project = pcall(require, "project_nvim") +if not status_ok then + return +end +project.setup({ + ---@usage set to false to disable project.nvim. + --- This is on by default since it's currently the expected behavior. + active = true, + + on_config_done = nil, + + ---@usage set to true to disable setting the current-woriking directory + --- Manual mode doesn't automatically change your root directory, so you have + --- the option to manually do so using `:ProjectRoot` command. + manual_mode = false, + + ---@usage Methods of detecting the root directory + --- Allowed values: **"lsp"** uses the native neovim lsp + --- **"pattern"** uses vim-rooter like glob pattern matching. Here + --- order matters: if one is not detected, the other is used as fallback. You + --- can also delete or rearangne the detection methods. + -- detection_methods = { "lsp", "pattern" }, -- NOTE: lsp detection will get annoying with multiple langs in one project + detection_methods = { "pattern" }, + + ---@usage patterns used to detect root dir, when **"pattern"** is in detection_methods + patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json" ,"main*" }, + + ---@ Show hidden files in telescope when searching for files in a project + show_hidden = false, + + ---@usage When set to false, you will get a message when project.nvim changes your directory. + -- When set to false, you will get a message when project.nvim changes your directory. + silent_chdir = true, + + ---@usage list of lsp client names to ignore when using **lsp** detection. eg: { "efm", ... } + ignore_lsp = {}, + + ---@type string + ---@usage path to store the project history for use in telescope + datapath = vim.fn.stdpath("data"), +}) + +local tele_status_ok, telescope = pcall(require, "telescope") +if not tele_status_ok then + return +end + +telescope.load_extension('projects') diff --git a/lua/user/smartspit.lua b/lua/user/smartspit.lua new file mode 100644 index 0000000..94242c9 --- /dev/null +++ b/lua/user/smartspit.lua @@ -0,0 +1,18 @@ +local status_ok, smart_splits = pcall(require, "smart-splits") +if not status_ok then + return +end +smart_splits.setup({ + ignored_filetypes = { + "nofile", + "quickfix", + "qf", + "prompt", + }, + ignored_buftypes = { "nofile" }, +}) + +vim.keymap.set("n", "", require("smart-splits").resize_left) +vim.keymap.set("n", "", require("smart-splits").resize_down) +vim.keymap.set("n", "", require("smart-splits").resize_right) diff --git a/lua/user/snip/init.lua b/lua/user/snip/init.lua new file mode 100644 index 0000000..7383736 --- /dev/null +++ b/lua/user/snip/init.lua @@ -0,0 +1,49 @@ +local status_ok = pcall(require, "luasnip") +if not status_ok then + return +end + +local lpath = vim.fn.stdpath("config") .. "/my-snippets" + + +-- kalau mau di pakai snipetnya baru di buaka remarknya karena bikin berat kalau load terus dan ga di pakai + +-- require("luasnip.loaders.from_vscode").lazy_load() +-- -- specify the full path... +-- require("luasnip.loaders.from_vscode").lazy_load({ +-- paths = lpath .. "/B5-Snippets", +-- }) +-- require("luasnip.loaders.from_vscode").lazy_load({ +-- paths = lpath .. "/laravel-blade", +-- }) +-- require("luasnip.loaders.from_vscode").lazy_load({ +-- paths = lpath .. "/laravel-blade2", +-- }) +-- require("luasnip.loaders.from_vscode").lazy_load({ +-- paths = lpath .. "/laravel5", +-- }) +-- require("luasnip.loaders.from_vscode").lazy_load({ +-- paths = lpath .. "/javascript", +-- }) +require("luasnip.loaders.from_vscode").lazy_load({ + paths = lpath .. "/html", +}) +require("luasnip.loaders.from_vscode").lazy_load({ + paths = lpath .. "/javascript-snippet", +}) +-- require("luasnip.loaders.from_vscode").lazy_load({ +-- paths = lpath .. "/codeigniter4", +-- }) +-- require("luasnip.loaders.from_vscode").lazy_load({ +-- paths = lpath .. "/font-awesome", +-- }) +-- or relative to the directory of $MYVIMRC +--require("luasnip.loaders.from_vscode").load({ paths = lpath .. "/B5-Snippets" }) +--require("luasnip.loaders.from_vscode").load({ paths = lpath .. "/laravel-blade" }) +--require("luasnip.loaders.from_vscode").load({ paths = lpath .. "/laravel-blade2" }) +--require("luasnip.loaders.from_vscode").load({ paths = lpath .. "/laravel5" }) +--require("luasnip.loaders.from_vscode").load({ paths = lpath .. "/javascript" }) +require("luasnip.loaders.from_vscode").load({ paths = lpath .. "/html" }) +--require("luasnip.loaders.from_vscode").load({ paths = lpath .. "/codeigniter4" }) +--require("luasnip.loaders.from_vscode").load({ paths = lpath .. "/font-awesome" }) +require("luasnip.loaders.from_vscode").load({ paths = lpath .. "/javascript-snippet" }) diff --git a/lua/user/telescope.lua b/lua/user/telescope.lua new file mode 100644 index 0000000..047d3e0 --- /dev/null +++ b/lua/user/telescope.lua @@ -0,0 +1,96 @@ +local status_ok, telescope = pcall(require, "telescope") +if not status_ok then + return +end + +local actions = require "telescope.actions" + +telescope.setup { + defaults = { + + prompt_prefix = " ", + selection_caret = " ", + path_display = { "smart" }, + + mappings = { + i = { + [""] = actions.cycle_history_next, + [""] = actions.cycle_history_prev, + + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + + [""] = actions.close, + + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + + [""] = actions.select_default, + [""] = actions.select_horizontal, + [""] = actions.select_vertical, + [""] = actions.select_tab, + + [""] = actions.preview_scrolling_up, + [""] = actions.preview_scrolling_down, + + [""] = actions.results_scrolling_up, + [""] = actions.results_scrolling_down, + + [""] = actions.toggle_selection + actions.move_selection_worse, + [""] = actions.toggle_selection + actions.move_selection_better, + [""] = actions.send_to_qflist + actions.open_qflist, + [""] = actions.send_selected_to_qflist + actions.open_qflist, + [""] = actions.complete_tag, + [""] = actions.which_key, -- keys from pressing + }, + + n = { + [""] = actions.close, + [""] = actions.select_default, + [""] = actions.select_horizontal, + [""] = actions.select_vertical, + [""] = actions.select_tab, + + [""] = actions.toggle_selection + actions.move_selection_worse, + [""] = actions.toggle_selection + actions.move_selection_better, + [""] = actions.send_to_qflist + actions.open_qflist, + [""] = actions.send_selected_to_qflist + actions.open_qflist, + + ["j"] = actions.move_selection_next, + ["k"] = actions.move_selection_previous, + ["H"] = actions.move_to_top, + ["M"] = actions.move_to_middle, + ["L"] = actions.move_to_bottom, + + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + ["gg"] = actions.move_to_top, + ["G"] = actions.move_to_bottom, + + [""] = actions.preview_scrolling_up, + [""] = actions.preview_scrolling_down, + + [""] = actions.results_scrolling_up, + [""] = actions.results_scrolling_down, + + ["?"] = actions.which_key, + }, + }, + }, + pickers = { + -- Default configuration for builtin pickers goes here: + -- picker_name = { + -- picker_config_key = value, + -- ... + -- } + -- Now the picker_config_key will be applied every time you call this + -- builtin picker + }, + extensions = { + -- Your extension configuration goes here: + -- extension_name = { + -- extension_config_key = value, + -- } + -- please take a look at the readme of the extension you want to configure + }, +} diff --git a/lua/user/toggleterm.lua b/lua/user/toggleterm.lua new file mode 100644 index 0000000..d54bfa0 --- /dev/null +++ b/lua/user/toggleterm.lua @@ -0,0 +1,70 @@ +local status_ok, toggleterm = pcall(require, "toggleterm") +if not status_ok then + return +end + +toggleterm.setup({ + size = 20, + open_mapping = [[]], + hide_numbers = true, + shade_filetypes = {}, + shade_terminals = true, + shading_factor = 2, + start_in_insert = true, + insert_mappings = true, + persist_size = true, + direction = "float", + close_on_exit = true, + shell = vim.o.shell, + float_opts = { + border = "curved", + winblend = 0, + highlights = { + border = "Normal", + background = "Normal", + }, + }, +}) + +function _G.set_terminal_keymaps() + local opts = {noremap = true} + vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) + vim.api.nvim_buf_set_keymap(0, 't', 'jk', [[]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[h]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[j]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[k]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '', [[l]], opts) +end + +vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') + +local Terminal = require("toggleterm.terminal").Terminal +local lazygit = Terminal:new({ cmd = "lazygit", hidden = true }) + +function _LAZYGIT_TOGGLE() + lazygit:toggle() +end + +local node = Terminal:new({ cmd = "node", hidden = true }) + +function _NODE_TOGGLE() + node:toggle() +end + +local ncdu = Terminal:new({ cmd = "ncdu", hidden = true }) + +function _NCDU_TOGGLE() + ncdu:toggle() +end + +local htop = Terminal:new({ cmd = "htop", hidden = true }) + +function _HTOP_TOGGLE() + htop:toggle() +end + +local python = Terminal:new({ cmd = "python", hidden = true }) + +function _PYTHON_TOGGLE() + python:toggle() +end diff --git a/lua/user/tokyonight.lua b/lua/user/tokyonight.lua new file mode 100644 index 0000000..e76a352 --- /dev/null +++ b/lua/user/tokyonight.lua @@ -0,0 +1,40 @@ +local status_ok, tokyonight = pcall(require, "tokyonight") +if not status_ok then + return +end +tokyonight.setup({ + -- your configuration comes here + -- or leave it empty to use the default settings + style = "storm", -- The theme comes in three styles, `storm`, `moon`, a darker variant `night` and `day` + light_style = "day", -- The theme is used when the background is set to light + transparent = false, -- Enable this to disable setting the background color + terminal_colors = true, -- Configure the colors used when opening a `:terminal` in Neovim + styles = { + -- Style to be applied to different syntax groups + -- Value is any valid attr-list value for `:help nvim_set_hl` + -- comments = { italic = true }, + comments = { italic = true }, + keywords = { italic = true }, + functions = {}, + variables = {}, + -- Background styles. Can be "dark", "transparent" or "normal" + sidebars = "dark", -- style for sidebars, see below + floats = "dark", -- style for floating windows + }, + sidebars = { "qf", "help" }, -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]` + day_brightness = 0.2, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors + hide_inactive_statusline = false, -- Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**. + dim_inactive = false, -- dims inactive windows + lualine_bold = false, -- When `true`, section headers in the lualine theme will be bold + + --- You can override specific color groups to use other groups or a hex color + --- function will be called with a ColorScheme table + --@param colors ColorScheme + --on_colors = function(colors) end, + + --- You can override specific highlights to use other groups or a hex color + --- function will be called with a Highlights and ColorScheme table + --@param highlights Highlights + --@param colors ColorScheme + --on_highlights = function(highlights, colors) end, +}) diff --git a/lua/user/webdevicons.lua b/lua/user/webdevicons.lua new file mode 100644 index 0000000..ab4f05e --- /dev/null +++ b/lua/user/webdevicons.lua @@ -0,0 +1,1764 @@ +local status_ok, webicon = pcall(require, "nvim-web-devicons") +if not status_ok then + return +end +webicon.setup { + -- your personnal icons can go here (to override) + -- you can specify color or cterm_color instead of specifying both of them + -- DevIcon will be appended to `name` + override = { + [".babelrc"] = { + icon = "", + color = "#cbcb41", + cterm_color = "185", + name = "Babelrc", + }, + [".bash_profile"] = { + icon = "", + color = "#89e051", + cterm_color = "113", + name = "BashProfile", + }, + [".bashrc"] = { + icon = "", + color = "#89e051", + cterm_color = "113", + name = "Bashrc", + }, + [".DS_Store"] = { + icon = "", + color = "#41535b", + cterm_color = "239", + name = "DsStore", + }, + [".gitattributes"] = { + icon = "", + color = "#41535b", + cterm_color = "239", + name = "GitAttributes", + }, + [".gitconfig"] = { + icon = "", + color = "#41535b", + cterm_color = "239", + name = "GitConfig", + }, + [".gitignore"] = { + icon = "", + color = "#e24329", + cterm_color = "166", + name = "GitIgnore", + }, + [".gitlab-ci.yml"] = { + icon = "", + color = "#e24329", + cterm_color = "166", + name = "GitlabCI", + }, + [".gitmodules"] = { + icon = "", + color = "#41535b", + cterm_color = "239", + name = "GitModules", + }, + [".gvimrc"] = { + icon = "", + color = "#019833", + cterm_color = "29", + name = "Gvimrc", + }, + [".npmignore"] = { + icon = "", + color = "#E8274B", + cterm_color = "161", + name = "NPMIgnore", + }, + [".npmrc"] = { + icon = "", + color = "#E8274B", + cterm_color = "161", + name = "NPMrc", + }, + [".settings.json"] = { + icon = "", + color = "#854CC7", + cterm_color = "98", + name = "SettingsJson", + }, + [".vimrc"] = { + icon = "", + color = "#019833", + cterm_color = "29", + name = "Vimrc", + }, + [".zprofile"] = { + icon = "", + color = "#89e051", + cterm_color = "113", + name = "Zshprofile", + }, + [".zshenv"] = { + icon = "", + color = "#89e051", + cterm_color = "113", + name = "Zshenv", + }, + [".zshrc"] = { + icon = "", + color = "#89e051", + cterm_color = "113", + name = "Zshrc", + }, + ["Brewfile"] = { + icon = "", + color = "#701516", + cterm_color = "1", + name = "Brewfile", + }, + ["CMakeLists.txt"] = { + icon = "", + color = "#6d8086", + cterm_color = "66", + name = "CMakeLists", + }, + ["COMMIT_EDITMSG"] = { + icon = "", + color = "#41535b", + cterm_color = "239", + name = "GitCommit", + }, + ["COPYING"] = { + icon = "", + color = "#cbcb41", + cterm_color = "185", + name = "License", + }, + ["COPYING.LESSER"] = { + icon = "", + color = "#cbcb41", + cterm_color = "185", + name = "License", + }, + ["Dockerfile"] = { + icon = "", + color = "#0087c9", + cterm_color = "32", + name = "Dockerfile", + }, + ["Gemfile$"] = { + icon = "", + color = "#701516", + cterm_color = "1", + name = "Gemfile", + }, + ["R"] = { + icon = "ﳒ", + color = "#358a5b", + cterm_color = "65", + name = "R", + }, + ["Rmd"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "Rmd", + }, + ["Vagrantfile$"] = { + icon = "", + color = "#1563FF", + cterm_color = "27", + name = "Vagrantfile", + }, + ["_gvimrc"] = { + icon = "", + color = "#019833", + cterm_color = "29", + name = "Gvimrc", + }, + ["_vimrc"] = { + icon = "", + color = "#019833", + cterm_color = "29", + name = "Vimrc", + }, + ["ai"] = { + icon = "", + color = "#cbcb41", + cterm_color = "185", + name = "Ai", + }, + ["awk"] = { + icon = "", + color = "#4d5a5e", + cterm_color = "240", + name = "Awk", + }, + ["bash"] = { + icon = "", + color = "#89e051", + cterm_color = "113", + name = "Bash", + }, + ["bat"] = { + icon = "", + color = "#C1F12E", + cterm_color = "154", + name = "Bat", + }, + ["bmp"] = { + icon = "", + color = "#26a69a", + cterm_color = "36", + name = "Bmp", + }, + ["c"] = { + icon = "", + color = "#599eff", + cterm_color = "75", + name = "C", + }, + ["c++"] = { + icon = "", + color = "#f34b7d", + cterm_color = "204", + name = "CPlusPlus", + }, + ["cbl"] = { + icon = "⚙", + color = "#005ca5", + cterm_color = "25", + name = "Cobol", + }, + ["cc"] = { + icon = "", + color = "#f34b7d", + cterm_color = "204", + name = "CPlusPlus", + }, + ["cfg"] = { + icon = "", + color = "#ECECEC", + cterm_color = "255", + name = "Configuration", + }, + ["clj"] = { + icon = "", + color = "#8dc149", + cterm_color = "107", + name = "Clojure", + }, + ["cljc"] = { + icon = "", + color = "#8dc149", + cterm_color = "107", + name = "ClojureC", + }, + ["cljs"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "ClojureJS", + }, + ["cljd"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "ClojureDart", + }, + ["cmake"] = { + icon = "", + color = "#6d8086", + cterm_color = "66", + name = "CMake", + }, + ["cob"] = { + icon = "⚙", + color = "#005ca5", + cterm_color = "25", + name = "Cobol", + }, + ["cobol"] = { + icon = "⚙", + color = "#005ca5", + cterm_color = "25", + name = "Cobol", + }, + ["coffee"] = { + icon = "", + color = "#cbcb41", + cterm_color = "185", + name = "Coffee", + }, + ["conf"] = { + icon = "", + color = "#6d8086", + cterm_color = "66", + name = "Conf", + }, + ["config.ru"] = { + icon = "", + color = "#701516", + cterm_color = "1", + name = "ConfigRu", + }, + ["cp"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "Cp", + }, + ["cpp"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "Cpp", + }, + ["cpy"] = { + icon = "⚙", + color = "#005ca5", + cterm_color = "25", + name = "Cobol", + }, + ["cr"] = { + icon = "", + color = "#000000", + cterm_color = "16", + name = "Crystal", + }, + ["cs"] = { + icon = "", + color = "#596706", + cterm_color = "58", + name = "Cs", + }, + ["csh"] = { + icon = "", + color = "#4d5a5e", + cterm_color = "240", + name = "Csh", + }, + ["cson"] = { + icon = "", + color = "#cbcb41", + cterm_color = "185", + name = "Cson", + }, + ["css"] = { + icon = "", + color = "#42a5f5", + cterm_color = "75", + name = "Css", + }, + ["csv"] = { + icon = "", + color = "#89e051", + cterm_color = "113", + name = "Csv", + }, + ["cxx"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "Cxx", + }, + ["d"] = { + icon = "", + color = "#427819", + cterm_color = "64", + name = "D", + }, + ["dart"] = { + icon = "", + color = "#03589C", + cterm_color = "25", + name = "Dart", + }, + ["db"] = { + icon = "", + color = "#dad8d8", + cterm_color = "253", + name = "Db", + }, + ["desktop"] = { + icon = "", + color = "#563d7c", + cterm_color = "60", + name = "DesktopEntry", + }, + ["diff"] = { + icon = "", + color = "#41535b", + cterm_color = "239", + name = "Diff", + }, + ["doc"] = { + icon = "", + color = "#185abd", + cterm_color = "25", + name = "Doc", + }, + ["dockerfile"] = { + icon = "", + color = "#0087c9", + cterm_color = "32", + name = "Dockerfile", + }, + ["drl"] = { + icon = "", + color = "#ffafaf", + cterm_color = "217", + name = "Drools", + }, + ["dropbox"] = { + icon = "", + color = "#0061FE", + cterm_color = "27", + name = "Dropbox", + }, + ["dump"] = { + icon = "", + color = "#dad8d8", + cterm_color = "253", + name = "Dump", + }, + ["edn"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "Edn", + }, + ["eex"] = { + icon = "", + color = "#a074c4", + cterm_color = "140", + name = "Eex", + }, + ["ejs"] = { + icon = "", + color = "#cbcb41", + cterm_color = "185", + name = "Ejs", + }, + ["elm"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "Elm", + }, + ["epp"] = { + icon = "", + color = "#FFA61A", + cterm_color = "214", + name = "Epp", + }, + ["erb"] = { + icon = "", + color = "#701516", + cterm_color = "1", + name = "Erb", + }, + ["erl"] = { + icon = "", + color = "#B83998", + cterm_color = "132", + name = "Erl", + }, + ["ex"] = { + icon = "", + color = "#a074c4", + cterm_color = "140", + name = "Ex", + }, + ["exs"] = { + icon = "", + color = "#a074c4", + cterm_color = "140", + name = "Exs", + }, + ["f#"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "Fsharp", + }, + ["favicon.ico"] = { + icon = "", + color = "#cbcb41", + cterm_color = "185", + name = "Favicon", + }, + ["fnl"] = { + icon = "", + color = "#fff3d7", + cterm_color = "230", + name = "Fennel", + }, + ["fish"] = { + icon = "", + color = "#4d5a5e", + cterm_color = "240", + name = "Fish", + }, + ["fs"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "Fs", + }, + ["fsi"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "Fsi", + }, + ["fsscript"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "Fsscript", + }, + ["fsx"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "Fsx", + }, + ["gd"] = { + icon = "", + color = "#6d8086", + cterm_color = "66", + name = "GDScript", + }, + ["gemspec"] = { + icon = "", + color = "#701516", + cterm_color = "1", + name = "Gemspec", + }, + ["gif"] = { + icon = "", + color = "#26a69a", + cterm_color = "36", + name = "Gif", + }, + ["git"] = { + icon = "", + color = "#F14C28", + cterm_color = "202", + name = "GitLogo", + }, + ["glb"] = { + icon = "", + color = "#FFB13B", + cterm_color = "215", + name = "BinaryGLTF", + }, + ["go"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "Go", + }, + ["godot"] = { + icon = "", + color = "#6d8086", + cterm_color = "66", + name = "GodotProject", + }, + ["graphql"] = { + icon = "", + color = "#e535ab", + cterm_color = "169", + name = "GraphQL", + }, + ["gruntfile"] = { + icon = "", + color = "#e37933", + cterm_color = "173", + name = "Gruntfile", + }, + ["gulpfile"] = { + icon = "", + color = "#cc3e44", + cterm_color = "167", + name = "Gulpfile", + }, + ["h"] = { + icon = "", + color = "#a074c4", + cterm_color = "140", + name = "H", + }, + ["haml"] = { + icon = "", + color = "#eaeae1", + cterm_color = "254", + name = "Haml", + }, + ["hbs"] = { + icon = "", + color = "#f0772b", + cterm_color = "208", + name = "Hbs", + }, + ["heex"] = { + icon = "", + color = "#a074c4", + cterm_color = "140", + name = "Heex", + }, + ["hh"] = { + icon = "", + color = "#a074c4", + cterm_color = "140", + name = "Hh", + }, + ["hpp"] = { + icon = "", + color = "#a074c4", + cterm_color = "140", + name = "Hpp", + }, + ["hrl"] = { + icon = "", + color = "#B83998", + cterm_color = "132", + name = "Hrl", + }, + ["hs"] = { + icon = "", + color = "#a074c4", + cterm_color = "140", + name = "Hs", + }, + ["htm"] = { + icon = "", + color = "#e34c26", + cterm_color = "166", + name = "Htm", + }, + ["html"] = { + icon = "", + color = "#e44d26", + cterm_color = "166", + name = "Html", + }, + ["hxx"] = { + icon = "", + color = "#a074c4", + cterm_color = "140", + name = "Hxx", + }, + ["ico"] = { + icon = "", + color = "#cbcb41", + cterm_color = "185", + name = "Ico", + }, + ["import"] = { + icon = "", + color = "#ECECEC", + cterm_color = "255", + name = "ImportConfiguration", + }, + ["ini"] = { + icon = "", + color = "#6d8086", + cterm_color = "66", + name = "Ini", + }, + ["java"] = { + icon = "", + color = "#cc3e44", + cterm_color = "167", + name = "Java", + }, + ["jl"] = { + icon = "", + color = "#a270ba", + cterm_color = "133", + name = "Jl", + }, + ["jpeg"] = { + icon = "", + color = "#26a69a", + cterm_color = "36", + name = "Jpeg", + }, + ["jpg"] = { + icon = "", + color = "#26a69a", + cterm_color = "36", + name = "Jpg", + }, + ["js"] = { + icon = "", + color = "#efd81d", + cterm_color = "220", + name = "Js", + }, + ["json"] = { + icon = "ﬥ", + color = "#cbcb41", + cterm_color = "185", + name = "Json", + }, + ["json5"] = { + icon = "", + color = "#cbcb41", + cterm_color = "185", + name = "Json5", + }, + ["jsx"] = { + icon = "ﰆ", + color = "#519aba", + cterm_color = "67", + name = "Jsx", + }, + ["ksh"] = { + icon = "", + color = "#4d5a5e", + cterm_color = "240", + name = "Ksh", + }, + ["kt"] = { + icon = "", + color = "#F88A02", + cterm_color = "208", + name = "Kotlin", + }, + ["kts"] = { + icon = "", + color = "#F88A02", + cterm_color = "208", + name = "KotlinScript", + }, + ["leex"] = { + icon = "", + color = "#a074c4", + cterm_color = "140", + name = "Leex", + }, + ["less"] = { + icon = "", + color = "#563d7c", + cterm_color = "60", + name = "Less", + }, + ["lhs"] = { + icon = "", + color = "#a074c4", + cterm_color = "140", + name = "Lhs", + }, + ["LICENSE"] = { + icon = "", + color = "#ff5722", + cterm_color = "202", + name = "License", + }, + ["lua"] = { + icon = "", + color = "#51a0cf", + cterm_color = "74", + name = "Lua", + }, + ["luau"] = { + icon = "", + color = "#51a0cf", + cterm_color = "74", + name = "Luau", + }, + ["makefile"] = { + icon = "", + color = "#6d8086", + cterm_color = "66", + name = "Makefile", + }, + ["markdown"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "Markdown", + }, + ["material"] = { + icon = "", + color = "#B83998", + cterm_color = "132", + name = "Material", + }, + ["md"] = { + icon = "", + color = "#42a5f5", + cterm_color = "75", + name = "Md", + }, + ["mdx"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "Mdx", + }, + ["mint"] = { + icon = "", + color = "#87c095", + cterm_color = "108", + name = "Mint", + }, + ["mix.lock"] = { + icon = "", + color = "#a074c4", + cterm_color = "140", + name = "MixLock", + }, + ["mjs"] = { + icon = "", + color = "#f1e05a", + cterm_color = "221", + name = "Mjs", + }, + ["ml"] = { + icon = "λ", + color = "#e37933", + cterm_color = "173", + name = "Ml", + }, + ["mli"] = { + icon = "λ", + color = "#e37933", + cterm_color = "173", + name = "Mli", + }, + ["mo"] = { + icon = "∞", + color = "#9772FB", + cterm_color = "99", + name = "Motoko", + }, + ["mustache"] = { + icon = "", + color = "#e37933", + cterm_color = "173", + name = "Mustache", + }, + ["nim"] = { + icon = "", + color = "#f3d400", + cterm_color = "220", + name = "Nim", + }, + ["nix"] = { + icon = "", + color = "#7ebae4", + cterm_color = "110", + name = "Nix", + }, + ["node_modules"] = { + icon = "", + color = "#E8274B", + cterm_color = "161", + name = "NodeModules", + }, + ["opus"] = { + icon = "", + color = "#F88A02", + cterm_color = "208", + name = "OPUS", + }, + ["otf"] = { + icon = "", + color = "#ECECEC", + cterm_color = "255", + name = "OpenTypeFont", + }, + ["package.json"] = { + icon = "", + color = "#8bc34a", + cterm_color = "113", + name = "PackageJson", + }, + ["package-lock.json"] = { + icon = "", + color = "#7a0d21", + cterm_color = "1", + name = "PackageLockJson", + }, + ["pck"] = { + icon = "", + color = "#6d8086", + cterm_color = "66", + name = "PackedResource", + }, + ["pdf"] = { + icon = "", + color = "#b30b00", + cterm_color = "124", + name = "Pdf", + }, + ["php"] = { + icon = "", + color = "#a074c4", + cterm_color = "140", + name = "Php", + }, + ["pl"] = { + icon = "﨩", + color = "#9575cd", + cterm_color = "104", + name = "Pl", + }, + ["pm"] = { + icon = "﨩", + color = "#9575cd", + cterm_color = "104", + name = "Pm", + }, + ["png"] = { + icon = "", + color = "#26a69a", + cterm_color = "36", + name = "Png", + }, + ["pp"] = { + icon = "", + color = "#FFA61A", + cterm_color = "214", + name = "Pp", + }, + ["ppt"] = { + icon = "", + color = "#cb4a32", + cterm_color = "167", + name = "Ppt", + }, + ["pro"] = { + icon = "", + color = "#e4b854", + cterm_color = "179", + name = "Prolog", + }, + ["Procfile"] = { + icon = "", + color = "#a074c4", + cterm_color = "140", + name = "Procfile", + }, + ["ps1"] = { + icon = "", + color = "#4d5a5e", + cterm_color = "240", + name = "PromptPs1", + }, + ["psb"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "Psb", + }, + ["psd"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "Psd", + }, + ["py"] = { + icon = "", + color = "#ffbc03", + cterm_color = "214", + name = "Py", + }, + ["pyc"] = { + icon = "", + color = "#ffe291", + cterm_color = "222", + name = "Pyc", + }, + ["pyd"] = { + icon = "", + color = "#ffe291", + cterm_color = "222", + name = "Pyd", + }, + ["pyo"] = { + icon = "", + color = "#ffe291", + cterm_color = "222", + name = "Pyo", + }, + ["query"] = { + icon = "", + color = "#90a850", + cterm_color = "107", + name = "Query", + }, + ["r"] = { + icon = "ﳒ", + color = "#358a5b", + cterm_color = "65", + name = "R", + }, + ["rake"] = { + icon = "", + color = "#701516", + cterm_color = "1", + name = "Rake", + }, + ["rakefile"] = { + icon = "", + color = "#701516", + cterm_color = "1", + name = "Rakefile", + }, + ["rb"] = { + icon = "", + color = "#701516", + cterm_color = "1", + name = "Rb", + }, + ["rlib"] = { + icon = "", + color = "#dea584", + cterm_color = "180", + name = "Rlib", + }, + ["rmd"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "Rmd", + }, + ["rproj"] = { + icon = "鉶", + color = "#358a5b", + cterm_color = "65", + name = "Rproj", + }, + ["rs"] = { + icon = "", + color = "#dea584", + cterm_color = "180", + name = "Rs", + }, + ["rss"] = { + icon = "", + color = "#FB9D3B", + cterm_color = "215", + name = "Rss", + }, + ["sass"] = { + icon = "", + color = "#f55385", + cterm_color = "204", + name = "Sass", + }, + ["sbt"] = { + icon = "", + color = "#cc3e44", + cterm_color = "167", + name = "sbt", + }, + ["scala"] = { + icon = "", + color = "#f44336", + cterm_color = "203", + name = "Scala", + }, + ["scm"] = { + icon = "ﬦ", + color = "#000000", + cterm_color = "16", + name = "Scheme", + }, + ["scss"] = { + icon = "", + color = "#f55385", + cterm_color = "204", + name = "Scss", + }, + ["sh"] = { + icon = "", + color = "#ff7043", + cterm_color = "203", + name = "Sh", + }, + ["sig"] = { + icon = "λ", + color = "#e37933", + cterm_color = "173", + name = "Sig", + }, + ["slim"] = { + icon = "", + color = "#e34c26", + cterm_color = "166", + name = "Slim", + }, + ["sln"] = { + icon = "", + color = "#854CC7", + cterm_color = "98", + name = "Sln", + }, + ["sml"] = { + icon = "λ", + color = "#e37933", + cterm_color = "173", + name = "Sml", + }, + ["sql"] = { + icon = "", + color = "#dad8d8", + cterm_color = "253", + name = "Sql", + }, + ["sqlite"] = { + icon = "", + color = "#dad8d8", + cterm_color = "253", + name = "Sql", + }, + ["sqlite3"] = { + icon = "", + color = "#dad8d8", + cterm_color = "253", + name = "Sql", + }, + ["styl"] = { + icon = "", + color = "#8dc149", + cterm_color = "107", + name = "Styl", + }, + ["sublime"] = { + icon = "", + color = "#e37933", + cterm_color = "173", + name = "Suo", + }, + ["suo"] = { + icon = "", + color = "#854CC7", + cterm_color = "98", + name = "Suo", + }, + ["sv"] = { + icon = "", + color = "#019833", + cterm_color = "29", + name = "SystemVerilog", + }, + ["svelte"] = { + icon = "", + color = "#ff3e00", + cterm_color = "202", + name = "Svelte", + }, + ["svh"] = { + icon = "", + color = "#019833", + cterm_color = "29", + name = "SystemVerilog", + }, + ["svg"] = { + icon = "ﰟ", + color = "#FFB13B", + cterm_color = "215", + name = "Svg", + }, + ["swift"] = { + icon = "ﯣ", + color = "#e37933", + cterm_color = "173", + name = "Swift", + }, + ["t"] = { + icon = "", + color = "#519aba", + cterm_color = "67", + name = "Tor", + }, + ["tbc"] = { + icon = "﯑", + color = "#1e5cb3", + cterm_color = "25", + name = "Tcl", + }, + ["tcl"] = { + icon = "﯑", + color = "#1e5cb3", + cterm_color = "25", + name = "Tcl", + }, + ["terminal"] = { + icon = "", + color = "#31B53E", + cterm_color = "71", + name = "Terminal", + }, + ["tex"] = { + icon = "ﭨ", + color = "#3D6117", + cterm_color = "58", + name = "Tex", + }, + ["toml"] = { + icon = "", + color = "#6d8086", + cterm_color = "66", + name = "Toml", + }, + ["tres"] = { + icon = "", + color = "#cbcb41", + cterm_color = "185", + name = "TextResource", + }, + ["ts"] = { + icon = "ﯤ", + color = "#519aba", + cterm_color = "67", + name = "Ts", + }, + ["tscn"] = { + icon = "", + color = "#a074c4", + cterm_color = "140", + name = "TextScene", + }, + ["tsx"] = { + icon = "ﰆ", + color = "#519aba", + cterm_color = "67", + name = "Tsx", + }, + ["twig"] = { + icon = "", + color = "#8dc149", + cterm_color = "107", + name = "Twig", + }, + ["txt"] = { + icon = "", + color = "#89e051", + cterm_color = "113", + name = "Txt", + }, + ["v"] = { + icon = "", + color = "#019833", + cterm_color = "29", + name = "Verilog", + }, + ["vh"] = { + icon = "", + color = "#019833", + cterm_color = "29", + name = "Verilog", + }, + ["vhd"] = { + icon = "", + color = "#019833", + cterm_color = "29", + name = "VHDL", + }, + ["vhdl"] = { + icon = "", + color = "#019833", + cterm_color = "29", + name = "VHDL", + }, + ["vim"] = { + icon = "", + color = "#019833", + cterm_color = "29", + name = "Vim", + }, + ["vue"] = { + icon = "﵂", + color = "#8dc149", + cterm_color = "107", + name = "Vue", + }, + ["webmanifest"] = { + icon = "", + color = "#f1e05a", + cterm_color = "221", + name = "Webmanifest", + }, + ["webp"] = { + icon = "", + color = "#26a69a", + cterm_color = "36", + name = "Webp", + }, + ["webpack"] = { + icon = "ﰩ", + color = "#519aba", + cterm_color = "67", + name = "Webpack", + }, + ["xcplayground"] = { + icon = "", + color = "#e37933", + cterm_color = "173", + name = "XcPlayground", + }, + ["xls"] = { + icon = "", + color = "#207245", + cterm_color = "23", + name = "Xls", + }, + ["xml"] = { + icon = "謹", + color = "#e37933", + cterm_color = "173", + name = "Xml", + }, + ["xul"] = { + icon = "", + color = "#e37933", + cterm_color = "173", + name = "Xul", + }, + ["yaml"] = { + icon = "", + color = "#6d8086", + cterm_color = "66", + name = "Yaml", + }, + ["yml"] = { + icon = "", + color = "#f44336", + cterm_color = "203", + name = "Yml", + }, + ["zig"] = { + icon = "", + color = "#f69a1b", + cterm_color = "208", + name = "Zig", + }, + ["zsh"] = { + icon = "", + color = "#89e051", + cterm_color = "113", + name = "Zsh", + }, + ["sol"] = { + icon = "ﲹ", + color = "#519aba", + cterm_color = "67", + name = "Solidity", + }, + [".env"] = { + icon = "", + color = "#faf743", + cterm_color = "227", + name = "Env", + }, + ["prisma"] = { + icon = "卑", + color = "#ffffff", + cterm_color = "231", + name = "Prisma", + }, + ["lock"] = { + icon = "", + color = "#ffd54f", + cterm_color = "221", + name = "Lock", + }, + ["log"] = { + icon = "", + color = "#ffffff", + cterm_color = "231", + name = "Log", + }, + -- More + [".svgrrc"] = { + icon = "ﰆ", + color = "#ffb300", + cterm_color = "214", + name = "Svgrrc", + }, + ["rar"] = { + icon = "遲", + color = "#afb42b", + cterm_color = "142", + name = "Rar", + }, + ["zip"] = { + icon = "", + color = "#afb42b", + cterm_color = "142", + name = "Zip", + }, + ["xz"] = { + icon = "", + color = "#afb42b", + cterm_color = "142", + name = "Xz", + }, + ["test.js"] = { + icon = "", + color = "#ffca28", + cterm_color = "220", + name = "TestJavascript", + }, + ["test.jsx"] = { + icon = "", + color = "#00bcd4", + cterm_color = "38", + name = "TestJavascriptReact", + }, + ["test.ts"] = { + icon = "", + color = "#00bcd4", + cterm_color = "38", + name = "TestTypescript", + }, + ["ttf"] = { + icon = "", + color = "#f44336", + cterm_color = "203", + name = "Ttf", + }, + ["woff"] = { + icon = "", + color = "#f44336", + cterm_color = "203", + name = "WebOpenFontFormat", + }, + ["woff2"] = { + icon = "", + color = "#f44336", + cterm_color = "203", + name = "WebOpenFontFormat", + }, + ["mp3"] = { + icon = "", + color = "#f44336", + cterm_color = "203", + name = "Mp3", + }, + ["wav"] = { + icon = "", + color = "#f44336", + cterm_color = "203", + name = "Wav", + }, + ["mp4"] = { + icon = "", + color = "#ff9800", + cterm_color = "208", + name = "Mp4", + }, + ["jar"] = { + icon = "", + color = "#f44336", + cterm_color = "203", + name = "Jar", + }, + ["class"] = { + icon = "﯈", + color = "#1e88e5", + cterm_color = "32", + name = "JavaClass", + }, + ["xlsx"] = { + icon = "", + color = "#207245", + cterm_color = "23", + name = "Excel", + }, + ["hex"] = { + icon = "", + color = "#26a69a", + cterm_color = "36", + name = "Hex", + }, + ["bin"] = { + icon = "", + color = "#26a69a", + cterm_color = "36", + name = "Bin", + }, + ["dat"] = { + icon = "", + color = "#26a69a", + cterm_color = "36", + name = "Dat", + }, + ["asm"] = { + icon = "ﬧ", + color = "#ff6e40", + cterm_color = "203", + name = "Asm", + }, + ["abc"] = { + icon = "", + color = "#ff5722", + cterm_color = "202", + name = "Abc", + }, + ["ino"] = { + icon = "ﯢ", + color = "#00979c", + cterm_color = "31", + name = "Arduino", + }, + ["babel.config.js"] = { + icon = "", + color = "#fdd835", + cterm_color = "221", + name = "BabelConfig", + }, + ["yarn.lock"] = { + icon = "", + color = "#0288d1", + cterm_color = "32", + name = "YarnLock", + }, + ["yarn-error.log"] = { + icon = "", + color = "#0288d1", + cterm_color = "32", + name = "YarnError", + }, + ["bf"] = { + icon = "", + color = "#ff4081", + cterm_color = "204", + name = "Bf", + }, + ["exe"] = { + icon = "", + color = "#e64a19", + cterm_color = "166", + name = "Exe", + }, + ["docx"] = { + icon = "", + color = "#185abd", + cterm_color = "25", + name = "Docx", + }, + ["rtf"] = { + icon = "", + color = "#89e051", + cterm_color = "113", + name = "Rtf", + }, + ["tif"] = { + icon = "", + color = "#26a69a", + cterm_color = "36", + name = "Tif", + }, + ["tiff"] = { + icon = "", + color = "#26a69a", + cterm_color = "36", + name = "Tiff", + }, + ["pptx"] = { + icon = "", + color = "#d14524", + cterm_color = "166", + name = "Pptx", + }, + ["p"] = { + icon = "", + color = "#e4b854", + cterm_color = "179", + name = "P", + }, + [".prettierrc.json"] = { + icon = "", + color = "#ea5e5e", + cterm_color = "167", + name = "Prettier", + }, + [".prettierrc.yml"] = { + icon = "", + color = "#ea5e5e", + cterm_color = "167", + name = "Prettier", + }, + [".prettierrc.yaml"] = { + icon = "", + color = "#ea5e5e", + cterm_color = "167", + name = "Prettier", + }, + [".prettierrc.js"] = { + icon = "", + color = "#ea5e5e", + cterm_color = "167", + name = "Prettier", + }, + [".prettierrc.toml"] = { + icon = "", + color = "#ea5e5e", + cterm_color = "167", + name = "Prettier", + }, + ["obj"] = { + icon = "", + color = "#29b6f6", + cterm_color = "39", + name = "Obj", + }, + ["fbx"] = { + icon = "", + color = "#29b6f6", + cterm_color = "39", + name = "Fbx", + }, + ["deb"] = { + icon = "", + color = "#ff0283", + cterm_color = "198", + name = "Deb", + }, + ["rpm"] = { + icon = "", + color = "#f44336", + cterm_color = "203", + name = "Rpm", + }, + ["robots.txt"] = { + icon = "ﮧ", + color = "#ff5252", + cterm_color = "203", + name = "Robots", + }, + ["robot"] = { + icon = "ﮧ", + color = "#00bfa5", + cterm_color = "37", + name = "Robot", + }, + ["CONTRIBUTING.md"] = { + icon = "", + color = "#ffca28", + cterm_color = "220", + name = "CONTRIBUTING.md", + }, + ["README.md"] = { + icon = "", + color = "#42a5f5", + cterm_color = "75", + name = "README.md", + }, + ["razor"] = { + icon = "", + color = "#42a5f5", + cterm_color = "75", + name = "razor", + }, + ["sc"] = { + icon = "", + color = "#f44336", + cterm_color = "203", + name = "sc", + }, + ["key"] = { + icon = "", + color = "#26a69a", + cterm_color = "36", + name = "Key", + }, + ["gmi"] = { + icon = "爵", + color = "#81c784", + cterm_color = "114", + name = "gmi", + }, + ["gmni"] = { + icon = "爵", + color = "#81c784", + cterm_color = "114", + name = "gmni", + }, + ["gemini"] = { + icon = "爵", + color = "#81c784", + cterm_color = "114", + name = "gemini", + }, + ["yang"] = { + icon = "ﭾ", + color = "#42a5f5", + cterm_color = "75", + name = "Yang", + }, + ["windi.config.ts"] = { + icon = "煮", + color = "#42a5f5", + cterm_color = "75", + name = "windi.config.ts", + }, + ["windi.config.js"] = { + icon = "煮", + color = "#42a5f5", + cterm_color = "75", + name = "windi.config.js", + }, + ["xaml"] = { + icon = "ﭲ", + color = "#42a5f5", + cterm_color = "75", + name = "xaml", + }, + ["lib"] = { + icon = "", + color = "#8bc34a", + cterm_color = "113", + name = "Lib", + }, + ["liquid"] = { + icon = "懲", + color = "#42a5f5", + cterm_color = "75", + name = "Liquid", + }, + ["vite.config.js"] = { + icon = "", + color = "#ffab00", + cterm_color = "214", + name = "vite.config.js", + }, + ["nuxt.config.js"] = { + icon = "行", + color = "#00e676", + cterm_color = "42", + name = "nuxt.config.js", + }, + ["todo"] = { + icon = "", + color = "#7cb342", + cterm_color = "107", + name = "todo", + }, + ["http"] = { + icon = "爵", + color = "#e53935", + cterm_color = "167", + name = "http", + }, + ["cake"] = { + icon = "", + color = "#ff7043", + cterm_color = "203", + name = "cake", + }, + }, + -- globally enable different highlight colors per icon (default to true) + -- if set to false all icons will have the default icon's color + color_icons = true, + -- globally enable default icons (default to false) + -- will get overriden by `get_icons` option + default = true, +} diff --git a/lua/user/whichkey.lua b/lua/user/whichkey.lua new file mode 100644 index 0000000..a36d7a5 --- /dev/null +++ b/lua/user/whichkey.lua @@ -0,0 +1,227 @@ +local status_ok, which_key = pcall(require, "which-key") +if not status_ok then + return +end + +local setup = { + plugins = { + marks = true, -- shows a list of your marks on ' and ` + registers = true, -- shows your registers on " in NORMAL or in INSERT mode + spelling = { + enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions + suggestions = 20, -- how many suggestions should be shown in the list? + }, + -- the presets plugin, adds help for a bunch of default keybindings in Neovim + -- No actual key bindings are created + presets = { + operators = false, -- adds help for operators like d, y, ... and registers them for motion / text object completion + motions = true, -- adds help for motions + text_objects = true, -- help for text objects triggered after entering an operator + windows = true, -- default bindings on + nav = true, -- misc bindings to work with windows + z = true, -- bindings for folds, spelling and others prefixed with z + g = true, -- bindings for prefixed with g + }, + }, + -- add operators that will trigger motion and text object completion + -- to enable all native operators, set the preset / operators plugin above + -- operators = { gc = "Comments" }, + key_labels = { + -- override the label used to display some keys. It doesn't effect WK in any other way. + -- For example: + -- [""] = "SPC", + -- [""] = "RET", + -- [""] = "TAB", + }, + icons = { + breadcrumb = "»", -- symbol used in the command line area that shows your active key combo + separator = "➜", -- symbol used between a key and it's label + group = "+", -- symbol prepended to a group + }, + popup_mappings = { + scroll_down = "", -- binding to scroll down inside the popup + scroll_up = "", -- binding to scroll up inside the popup + }, + window = { + border = "rounded", -- none, single, double, shadow + position = "bottom", -- bottom, top + margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left] + padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left] + winblend = 0, + }, + layout = { + height = { min = 4, max = 25 }, -- min and max height of the columns + width = { min = 20, max = 50 }, -- min and max width of the columns + spacing = 3, -- spacing between columns + align = "left", -- align columns left, center or right + }, + ignore_missing = true, -- enable this to hide mappings for which you didn't specify a label + hidden = { "", "", "", "", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate + show_help = true, -- show help message on the command line when the popup is visible + triggers = "auto", -- automatically setup triggers + -- triggers = {""} -- or specify a list manually + triggers_blacklist = { + -- list of mode / prefixes that should never be hooked by WhichKey + -- this is mostly relevant for key maps that start with a native binding + -- most people should not need to change this + i = { "j", "k" }, + v = { "j", "k" }, + }, +} + +local opts = { + mode = "n", -- NORMAL mode + prefix = "", + buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = true, -- use `nowait` when creating keymaps +} + +local opts2 = { + mode = "v", -- NORMAL mode + prefix = "", + buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = true, -- use `nowait` when creating keymaps +} + +local trn = "" +if vim.fn.has("win32") then + trn = "pwsh" +end + +local mappings2 = { + ["/"] = { "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", "Commet Block" }, +} +local mappings = { + ["a"] = { "Alpha", "Alpha" }, + ["b"] = { + "lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown{previewer = false})", + "Buffers", + }, + --["e"] = { "NvimTreeToggle", "Explorer" }, + ["e"] = { "NvimTreeToggle", "Explorer" }, + ["w"] = { "w!", "Save" }, + ["q"] = { "q!", "Quit" }, + ["c"] = { "Bdelete!", "Close Buffer" }, + ["h"] = { "nohlsearch", "No Highlight" }, + ["f"] = { + "Telescope find_files ", + "Find files", + }, + ["F"] = { "Telescope live_grep theme=ivy", "Find Text" }, + ["P"] = { "lua require('telescope').extensions.projects.projects()", "Projects" }, + + ["/"] = { + function() + require("Comment.api").toggle.linewise.current() + end, + "Coment line", + }, + p = { + name = "Packer", + c = { "PackerCompile", "Compile" }, + i = { "PackerInstall", "Install" }, + s = { "PackerSync", "Sync" }, + S = { "PackerStatus", "Status" }, + u = { "PackerUpdate", "Update" }, + }, + + g = { + name = "Git", + g = { "lua _LAZYGIT_TOGGLE()", "Lazygit" }, + j = { "lua require 'gitsigns'.next_hunk()", "Next Hunk" }, + k = { "lua require 'gitsigns'.prev_hunk()", "Prev Hunk" }, + l = { "lua require 'gitsigns'.blame_line()", "Blame" }, + p = { "lua require 'gitsigns'.preview_hunk()", "Preview Hunk" }, + r = { "lua require 'gitsigns'.reset_hunk()", "Reset Hunk" }, + R = { "lua require 'gitsigns'.reset_buffer()", "Reset Buffer" }, + s = { "lua require 'gitsigns'.stage_hunk()", "Stage Hunk" }, + u = { + "lua require 'gitsigns'.undo_stage_hunk()", + "Undo Stage Hunk", + }, + o = { "Telescope git_status", "Open changed file" }, + b = { "Telescope git_branches", "Checkout branch" }, + c = { "Telescope git_commits", "Checkout commit" }, + d = { + "Gitsigns diffthis HEAD", + "Diff", + }, + }, + + l = { + name = "LSP", + a = { "lua vim.lsp.buf.code_action()", "Code Action" }, + d = { + "Telescope diagnostics bufnr=0", + "Document Diagnostics", + }, + w = { + "Telescope diagnostics", + "Workspace Diagnostics", + }, + f = { "lua vim.lsp.buf.format{async=true}", "Format" }, + i = { "LspInfo", "Info" }, + I = { "Mason", "Installer Info" }, + j = { + "lua vim.lsp.diagnostic.goto_next()", + "Next Diagnostic", + }, + k = { + "lua vim.lsp.diagnostic.goto_prev()", + "Prev Diagnostic", + }, + l = { "lua vim.lsp.codelens.run()", "CodeLens Action" }, + q = { "lua vim.diagnostic.setloclist()", "Quickfix" }, + r = { "lua vim.lsp.buf.rename()", "Rename" }, + s = { "Telescope lsp_document_symbols", "Document Symbols" }, + S = { + "Telescope lsp_dynamic_workspace_symbols", + "Workspace Symbols", + }, + }, + s = { + name = "Search", + b = { "Telescope git_branches", "Checkout branch" }, + c = { "Telescope colorscheme", "Colorscheme" }, + h = { "Telescope help_tags", "Find Help" }, + M = { "Telescope man_pages", "Man Pages" }, + r = { "Telescope oldfiles", "Open Recent File" }, + R = { "Telescope registers", "Registers" }, + k = { "Telescope keymaps", "Keymaps" }, + C = { "Telescope commands", "Commands" }, + }, + + t = { + name = "Terminal", + n = { "lua _NODE_TOGGLE()", "Node" }, + u = { "lua _NCDU_TOGGLE()", "NCDU" }, + t = { "lua _HTOP_TOGGLE()", "Htop" }, + p = { "lua _PYTHON_TOGGLE()", "Python" }, + f = { "ToggleTerm direction=float" .. trn, "Float" }, + h = { "ToggleTerm size=10 direction=horizontal", "Horizontal" }, + v = { "ToggleTerm size=80 direction=vertical" .. trn, "Vertical" }, + }, + r = { + name = "Run", + s = { + 'autocmd bufwritepost [^_]*.sass,[^_]*.scss silent exec "!sass %:p %:r.css"', + "Auto Compile Sass", + }, + r = { "RunCode", "Run Code" }, + f = { "RunFile", "Run File" }, + p = { "RunProject", "Run Project" }, + g = { "ToggleTerm size=70 direction=verticalgradle run" .. trn, "Run Gradle" }, + m = { + "ToggleTerm size=70 direction=verticalmvn exec:java -Dexec.mainClass=com.pojokcode.App", + "Run MVN", + }, + }, +} + +which_key.setup(setup) +which_key.register(mappings, opts) +which_key.register(mappings2, opts2) diff --git a/lua/user/winbar.lua b/lua/user/winbar.lua new file mode 100644 index 0000000..cdf9bd9 --- /dev/null +++ b/lua/user/winbar.lua @@ -0,0 +1,151 @@ +local active = true +local icons = require("user.icons") +local excludes = function() + return vim.tbl_contains({ + "help", + "startify", + "dashboard", + "packer", + "neo-tree", + "neogitstatus", + "NvimTree", + "Trouble", + "alpha", + "lir", + "Outline", + "spectre_panel", + "toggleterm", + "DressingSelect", + "Jaq", + "harpoon", + "dap-repl", + "dap-terminal", + "dapui_console", + "dapui_hover", + "lab", + "notify", + "noice", + "", + } or {}, vim.bo.filetype) +end + +local get_filename = function() + local filename = vim.fn.expand("%:t") + local extension = vim.fn.expand("%:e") + local f = require("user.functions") + + if not f.isempty(filename) then + local file_icon, hl_group = require("nvim-web-devicons").get_icon(filename, extension, { default = true }) + + if f.isempty(file_icon) then + file_icon = icons.kind.File + end + + local buf_ft = vim.bo.filetype + + if buf_ft == "dapui_breakpoints" then + file_icon = icons.ui.Bug + end + + if buf_ft == "dapui_stacks" then + file_icon = icons.ui.Stacks + end + + if buf_ft == "dapui_scopes" then + file_icon = icons.ui.Scopes + end + + if buf_ft == "dapui_watches" then + file_icon = icons.ui.Watches + end + + -- if buf_ft == "dapui_console" then + -- file_icon = lvim.icons.ui.DebugConsole + -- end + + local navic_text = vim.api.nvim_get_hl_by_name("Normal", true) + vim.api.nvim_set_hl(0, "Winbar", { fg = navic_text.foreground }) + + return " " .. "%#" .. hl_group .. "#" .. file_icon .. "%*" .. " " .. "%#Winbar#" .. filename .. "%*" + end +end + +local get_gps = function() + local status_gps_ok, gps = pcall(require, "nvim-navic") + if not status_gps_ok then + return "" + end + + local status_ok, gps_location = pcall(gps.get_location, {}) + if not status_ok then + return "" + end + + if not gps.is_available() or gps_location == "error" then + return "" + end + + if not require("user.functions").isempty(gps_location) then + return "%#NavicSeparator#" .. icons.ui.ChevronRight .. "%* " .. gps_location + else + return "" + end +end + +local get_winbar = function() + if excludes() then + return + end + local f = require("user.functions") + local value = get_filename() + + local gps_added = false + if not f.isempty(value) then + local gps_value = get_gps() + value = value .. " " .. gps_value + if not f.isempty(gps_value) then + gps_added = true + end + end + + if not f.isempty(value) and f.get_buf_option("mod") then + -- TODO: replace with circle + local mod = "%#LspCodeLens#" .. icons.ui.Circle .. "%*" + if gps_added then + value = value .. " " .. mod + else + value = value .. mod + end + end + + local num_tabs = #vim.api.nvim_list_tabpages() + + if num_tabs > 1 and not f.isempty(value) then + local tabpage_number = tostring(vim.api.nvim_tabpage_get_number(0)) + value = value .. "%=" .. tabpage_number .. "/" .. tostring(num_tabs) + end + + local status_ok, _ = pcall(vim.api.nvim_set_option_value, "winbar", value, { scope = "local" }) + if not status_ok then + return + end +end + +vim.api.nvim_create_augroup("_winbar", {}) +if vim.fn.has("nvim-0.8") == 1 then + vim.api.nvim_create_autocmd( + { "CursorHoldI", "CursorHold", "BufWinEnter", "BufFilePost", "InsertEnter", "BufWritePost", "TabClosed" }, + { + group = "_winbar", + callback = function() + if active then + local status_ok, _ = pcall(vim.api.nvim_buf_get_var, 0, "lsp_floating_window") + if not status_ok then + -- TODO: + get_winbar() + end + end + end, + } + ) +end diff --git a/lua/user/yanky.lua b/lua/user/yanky.lua new file mode 100644 index 0000000..68f6901 --- /dev/null +++ b/lua/user/yanky.lua @@ -0,0 +1,17 @@ +local status_ok, yanky = pcall(require, "yanky") +if not status_ok then + return +end +yanky.setup({ + ring = { + history_length = 50, + storage = "memory", + }, + preserve_cursor_position = { + enabled = false, + }, +}) + +-- cycle through the yank history, only work after paste +vim.keymap.set("n", "[y", "(YankyCycleForward)") +vim.keymap.set("n", "]y", "(YankyCycleBackward)")