From bda5df7e1305234040b58176c05062937a4b9650 Mon Sep 17 00:00:00 2001 From: doryan Date: Sat, 11 Jan 2025 18:20:26 +0400 Subject: [PATCH] feat(config): add new branch --- init.lua | 51 +++++++++ lua/config/lazy.lua | 25 +++++ lua/config/plugins/acmp.lua | 5 + lua/config/plugins/autocomplete.lua | 95 ++++++++++++++++ lua/config/plugins/autotag.lua | 7 ++ lua/config/plugins/bufferline.lua | 89 +++++++++++++++ lua/config/plugins/colorizer.lua | 12 ++ lua/config/plugins/comment.lua | 10 ++ lua/config/plugins/dap.lua | 99 +++++++++++++++++ lua/config/plugins/dashboard.lua | 31 ++++++ lua/config/plugins/dropbar.lua | 4 + lua/config/plugins/gitsigns.lua | 48 ++++++++ lua/config/plugins/hover_actions.lua | 14 +++ lua/config/plugins/ibl.lua | 5 + lua/config/plugins/lsp_config.lua | 50 +++++++++ lua/config/plugins/lsp_diagnostic.lua | 5 + lua/config/plugins/lualine.lua | 59 ++++++++++ lua/config/plugins/luasnip.lua | 22 ++++ lua/config/plugins/navic.lua | 47 ++++++++ lua/config/plugins/neotree.lua | 52 +++++++++ lua/config/plugins/noice.lua | 15 +++ lua/config/plugins/prettier.lua | 19 ++++ lua/config/plugins/rustaceanvim.lua | 37 +++++++ lua/config/plugins/treesitter.lua | 8 ++ lua/config/utils/bufferline.lua | 95 ++++++++++++++++ lua/mappings.lua | 73 +++++++++++++ lua/plugins/core/init.lua | 152 ++++++++++++++++++++++++++ lua/plugins/secondary/init.lua | 50 +++++++++ 28 files changed, 1179 insertions(+) create mode 100644 init.lua create mode 100644 lua/config/lazy.lua create mode 100644 lua/config/plugins/acmp.lua create mode 100644 lua/config/plugins/autocomplete.lua create mode 100644 lua/config/plugins/autotag.lua create mode 100644 lua/config/plugins/bufferline.lua create mode 100644 lua/config/plugins/colorizer.lua create mode 100644 lua/config/plugins/comment.lua create mode 100755 lua/config/plugins/dap.lua create mode 100644 lua/config/plugins/dashboard.lua create mode 100644 lua/config/plugins/dropbar.lua create mode 100644 lua/config/plugins/gitsigns.lua create mode 100644 lua/config/plugins/hover_actions.lua create mode 100644 lua/config/plugins/ibl.lua create mode 100644 lua/config/plugins/lsp_config.lua create mode 100644 lua/config/plugins/lsp_diagnostic.lua create mode 100644 lua/config/plugins/lualine.lua create mode 100644 lua/config/plugins/luasnip.lua create mode 100644 lua/config/plugins/navic.lua create mode 100644 lua/config/plugins/neotree.lua create mode 100644 lua/config/plugins/noice.lua create mode 100644 lua/config/plugins/prettier.lua create mode 100644 lua/config/plugins/rustaceanvim.lua create mode 100644 lua/config/plugins/treesitter.lua create mode 100644 lua/config/utils/bufferline.lua create mode 100644 lua/mappings.lua create mode 100644 lua/plugins/core/init.lua create mode 100644 lua/plugins/secondary/init.lua diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..e479678 --- /dev/null +++ b/init.lua @@ -0,0 +1,51 @@ +local vanila_vim_autostart_commands = { + "set number", + "set clipboard=unnamedplus", + "set nowrap", + "set shiftwidth=4", + "set tabstop=4", +} + +vim.opt.fillchars = { eob = " " } + +for _, cmd in pairs(vanila_vim_autostart_commands) do + vim.cmd(cmd) +end + +if vim.lsp.inlay_hint then + vim.lsp.inlay_hint.enable(true, { 0 }) +end + +require("config.lazy") +require("config.plugins.acmp") +require("config.plugins.autotag") +require("config.plugins.autocomplete") +require("config.plugins.bufferline") +require("config.plugins.colorizer") +require("config.plugins.comment") +require("config.plugins.dap") +require("config.plugins.gitsigns") +require("config.plugins.ibl") +require("config.plugins.hover_actions") +require("config.plugins.lsp_config") +require("config.plugins.lsp_diagnostic") +require("config.plugins.lualine") +require("config.plugins.navic") +require("config.plugins.noice") +require("toggleterm").setup() +require("config.plugins.treesitter") +require("config.plugins.neotree") +require("config.plugins.prettier") +require("config.plugins.rustaceanvim") +require("huez").setup({}) +require("config.plugins.dropbar") +require("config.plugins.dashboard") + +vim.api.nvim_create_autocmd("BufWritePre", { + buffer = buffer, + callback = function() + vim.lsp.buf.format { async = false } + end +}) + +require("mappings") diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..547dbb1 --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,25 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +require("lazy").setup({ + spec = { + { import = "plugins.core", }, + { import = "plugins.secondary", }, + }, +}) diff --git a/lua/config/plugins/acmp.lua b/lua/config/plugins/acmp.lua new file mode 100644 index 0000000..59692fd --- /dev/null +++ b/lua/config/plugins/acmp.lua @@ -0,0 +1,5 @@ +-- require'cmp'.setup { +-- sources = { +-- { name = 'nvim_lsp' } +-- } +-- } diff --git a/lua/config/plugins/autocomplete.lua b/lua/config/plugins/autocomplete.lua new file mode 100644 index 0000000..3e78b0c --- /dev/null +++ b/lua/config/plugins/autocomplete.lua @@ -0,0 +1,95 @@ +local cmp = require "cmp" + +local kind_icons = { + Text = "", + Method = "󰆧", + Function = "󰊕", + Constructor = "", + Field = "", + Variable = "", + Class = "", + Interface = "", + Module = "", + Property = "󰜢", + Unit = "", + Value = "󰎠", + Enum = "", + Keyword = "󰌋", + Snippet = "", + Color = "󰏘", + File = "󰈙", + Reference = "", + Folder = "󰉋", + EnumMember = "", + Constant = "󰏿", + Struct = "", + Event = "", + Operator = "󰆕", + TypeParameter = "󰅲", +} + +cmp.setup{ + completion = { completeopt = "menu,menuone" }, + + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + + formatting = { + format = function(entry, vim_item) + -- Kind icons + vim_item.kind = string.format('\t%s %s\t', kind_icons[vim_item.kind], vim_item.kind) -- This concatenates the icons with the name of the item kind + -- Source + vim_item.menu = ({ + buffer = "[Buffer]", + nvim_lsp = "[LSP]", + luasnip = "[LuaSnip]", + nvim_lua = "[Lua]", + latex_symbols = "[LaTeX]", + })[entry.source.name] + return vim_item + end + }, + + mapping = { + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.close(), + + [""] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }, + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + require("luasnip").expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + require("luasnip").jump(-1) + else + fallback() + end + end, { "i", "s" }), + }, + + sources = { + { name = "nvim_lsp" }, + { name = "buffer" }, + { name = "path" }, + }, +} diff --git a/lua/config/plugins/autotag.lua b/lua/config/plugins/autotag.lua new file mode 100644 index 0000000..3be1748 --- /dev/null +++ b/lua/config/plugins/autotag.lua @@ -0,0 +1,7 @@ +require('nvim-ts-autotag').setup({ + opts = { + enable_close = true, + enable_rename = true, + enable_close_on_slash = false + }, +}) diff --git a/lua/config/plugins/bufferline.lua b/lua/config/plugins/bufferline.lua new file mode 100644 index 0000000..243a646 --- /dev/null +++ b/lua/config/plugins/bufferline.lua @@ -0,0 +1,89 @@ +vim.opt.termguicolors = true + +local utils = require("config.utils.bufferline") + +require("bufferline").setup({ + highlights = { + background = { + italic = false, + }, + buffer_selected = { + bold = true, + }, + }, + options = { + themable = true, + get_element_icon = nil, + show_duplicate_prefix = true, + duplicates_across_groups = true, + auto_toggle_bufferline = true, + move_wraps_at_ends = false, + groups = { items = {}, options = { toggle_hidden_on_enter = true } }, + mode = "buffers", + numbers = "none", + close_command = function(bufnr) + utils.buf_kill("bd", bufnr, false) + end, + right_mouse_command = "vert sbuffer %d", + left_mouse_command = "buffer %d", + middle_mouse_command = nil, + name_formatter = function(buf) + if buf.name:match "%.md" then + return vim.fn.fnamemodify(buf.name, ":t:r") + end + end, + max_name_length = 18, + max_prefix_length = 15, + truncate_names = true, + tab_size = 18, + diagnostics = "nvim_lsp", + diagnostics_update_in_insert = false, + custom_filter = utils.custom_filter, + offsets = { + { + filetype = "undotree", + text = "Undotree", + highlight = "PanelHeading", + padding = 1, + }, + { + filetype = "NvimTree", + text = "Explorer", + highlight = "PanelHeading", + padding = 1, + }, + { + filetype = "DiffviewFiles", + text = "Diff View", + highlight = "PanelHeading", + padding = 1, + }, + { + filetype = "flutterToolsOutline", + text = "Flutter Outline", + highlight = "PanelHeading", + }, + { + filetype = "lazy", + text = "Lazy", + highlight = "PanelHeading", + padding = 1, + }, + }, + color_icons = true, + show_close_icon = false, + show_tab_indicators = true, + persist_buffer_sort = true, + separator_style = "thin", + enforce_regular_tabs = false, + always_show_bufferline = false, + hover = { + enabled = false, + delay = 200, + reveal = { "close" }, + }, + sort_by = "id", + debug = { logging = false }, + }, + +}) diff --git a/lua/config/plugins/colorizer.lua b/lua/config/plugins/colorizer.lua new file mode 100644 index 0000000..2c9bb5b --- /dev/null +++ b/lua/config/plugins/colorizer.lua @@ -0,0 +1,12 @@ + require("colorizer").setup { + filetypes = { "scss", "sass", "css", "html", "jsx", "tsx" }, + user_default_options = { + css = true, + css_fn = true, + mode = "background", + tailwind = true, + sass = { enable = true, parsers = { "css" }, }, + always_update = false + }, + buftypes = {}, + } diff --git a/lua/config/plugins/comment.lua b/lua/config/plugins/comment.lua new file mode 100644 index 0000000..f6b4df5 --- /dev/null +++ b/lua/config/plugins/comment.lua @@ -0,0 +1,10 @@ +require('Comment').setup({ + padding = true, + sticky = true, + toggler = { + line = '/', + }, + opleader = { + line = '/', + }, +}) diff --git a/lua/config/plugins/dap.lua b/lua/config/plugins/dap.lua new file mode 100755 index 0000000..19477da --- /dev/null +++ b/lua/config/plugins/dap.lua @@ -0,0 +1,99 @@ +local dap = require('dap') + +require("dap-vscode-js").setup({ + debugger_path = "/.local/share/lunarvim/site/pack/lazy/opt/vscode-js-debug", + debugger_cmd = { "js-debug-adapter" }, + adapters = { 'node-terminal' }, + }) + +dap.configurations.cpp = { + { + name = "Launch file", + type = "codelldb", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}', + stopOnEntry = false, + }, +} + +dap.configurations.c = dap.configurations.cpp +dap.configurations.rust = dap.configurations.cpp + +dap.adapters["pwa-node"] = { + type = "server", + host = "localhost", + port = "${port}", + executable = { + command = "node", + args = {os.getenv("HOME") .. "/.local/share/lvim/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js", "${port}"}, + } +} + +dap.configurations.javascript = { + { + type = "pwa-node", + request = "launch", + name = "Launch file", + program = "${file}", + cwd = "${workspaceFolder}", + }, +} + +dap.adapters.chrome = { + type = "executable", + command = "node", + args = {os.getenv("HOME") .. "/.local/share/lvim/mason/packages/chrome-debug-adapter/out/src/chromeDebug.js"}, +} + +dap.adapters.firefox = { + type = 'executable', + command = 'node', + args = {os.getenv('HOME') .. '/.local/share/lvim/mason/packages/firefox-debug-adapter/dist/adapter.bundle.js'}, +} + +dap.configurations.typescriptreact = { + { + name = 'Next.js: debug server-side', + type = "pwa-node", + request = "launch", + runtimeExecutable = "npm", + runtimeArgs = { "run", "dev" }, + cwd = "${workspaceFolder}", + }, + { + name = "Next.js: debug client-side with chrome", + type = "chrome", + request = "launch", + url = "http://localhost:3000" + }, + { + name = "Next.js: debug client-side with firefox", + type = "firefox", + request = "launch", + url = 'http://localhost:3000', + webRoot = '${workspaceFolder}', + firefoxExecutable = '/usr/bin/waterfox', + pathMappings = { + { + url = "webpack://_n_e/", + path = "${workspaceFolder}/" + } + }, + }, +} + +dap.configurations.javascriptreact = dap.configurations.typescriptreact; + +require("dapui").setup() + +local dap, dapui = require("dap"), require("dapui") + +dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open({}) +end + +vim.keymap.set('n', 'ui', require 'dapui'.toggle) + diff --git a/lua/config/plugins/dashboard.lua b/lua/config/plugins/dashboard.lua new file mode 100644 index 0000000..22ca324 --- /dev/null +++ b/lua/config/plugins/dashboard.lua @@ -0,0 +1,31 @@ +require('dashboard').setup { + theme = 'hyper', + config = { + week_header = { + enable = true, + }, + shortcut = { + { desc = '󰊳 Update', group = '@property', action = 'Lazy update', key = 'u' }, + { + icon = ' ', + icon_hl = '@variable', + desc = 'Files', + group = 'Label', + action = 'Telescope find_files', + key = 'f', + }, + { + desc = ' Apps', + group = 'DiagnosticHint', + action = 'Telescope app', + key = 'a', + }, + { + desc = ' dotfiles', + group = 'Number', + action = 'Telescope dotfiles', + key = 'd', + }, + }, + }, +} diff --git a/lua/config/plugins/dropbar.lua b/lua/config/plugins/dropbar.lua new file mode 100644 index 0000000..3c538a9 --- /dev/null +++ b/lua/config/plugins/dropbar.lua @@ -0,0 +1,4 @@ +require('dropbar').setup() +vim.ui.select = require('dropbar.utils.menu').select +vim.api.nvim_set_hl(0, 'DropBarMenuHoverEntry', { link = 'PmenuExtraSel' }) + diff --git a/lua/config/plugins/gitsigns.lua b/lua/config/plugins/gitsigns.lua new file mode 100644 index 0000000..6437554 --- /dev/null +++ b/lua/config/plugins/gitsigns.lua @@ -0,0 +1,48 @@ +require('gitsigns').setup { + signs = { + add = { text = '┃' }, + change = { text = '┃' }, + delete = { text = '' }, + topdelete = { text = '' }, + changedelete = { text = '┃' }, + untracked = { text = ' ' }, + }, + signs_staged = { + add = { text = '┃' }, + change = { text = '┃' }, + delete = { text = '' }, + topdelete = { text = '' }, + changedelete = { text = '┃' }, + untracked = { text = ' ' }, + }, + signcolumn = true, + numhl = false, + linehl = false, + word_diff = false, + 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 = ", - ", + sign_priority = 6, + status_formatter = nil, -- Use default + update_debounce = 200, + max_file_length = 40000, + preview_config = { + -- Options passed to nvim_open_win + border = "rounded", + style = "minimal", + relative = "cursor", + row = 0, + vcol = 1, + }, + yadm = { enable = false }, +} diff --git a/lua/config/plugins/hover_actions.lua b/lua/config/plugins/hover_actions.lua new file mode 100644 index 0000000..47a8420 --- /dev/null +++ b/lua/config/plugins/hover_actions.lua @@ -0,0 +1,14 @@ +require("hover").setup { + init = function() + require("hover.providers.lsp") + end, + preview_opts = { + border = 'single' + }, + preview_window = false, + title = true, + mouse_providers = { + 'LSP' + }, + mouse_delay = 1000 +} diff --git a/lua/config/plugins/ibl.lua b/lua/config/plugins/ibl.lua new file mode 100644 index 0000000..1b1a8cb --- /dev/null +++ b/lua/config/plugins/ibl.lua @@ -0,0 +1,5 @@ +require("ibl").setup({ + exclude = { + filetypes = { "dashboard" }, + } +}) diff --git a/lua/config/plugins/lsp_config.lua b/lua/config/plugins/lsp_config.lua new file mode 100644 index 0000000..2e026a0 --- /dev/null +++ b/lua/config/plugins/lsp_config.lua @@ -0,0 +1,50 @@ +local lspconfig = require("lspconfig") + +lspconfig.lua_ls.setup({ + settings = { + Lua = { + hint = { + enable = true, + }, + }, + } +}) + +lspconfig.eslint.setup({ + settings = { + codeActionOnSave = { + enable = true, + mode = "all", + }, + format = true, + } +}) + +lspconfig.ts_ls.setup({ + settings = { + typescript = { + inlayHints = { + includeInlayParameterNameHints = "all", -- 'none' | 'literals' | 'all' + includeInlayParameterNameHintsWhenArgumentMatchesName = false, + includeInlayFunctionParameterTypeHints = true, + includeInlayVariableTypeHints = true, + includeInlayVariableTypeHintsWhenTypeMatchesName = false, + includeInlayPropertyDeclarationTypeHints = true, + includeInlayFunctionLikeReturnTypeHints = true, + includeInlayEnumMemberValueHints = true, + }, + }, + javascript = { + inlayHints = { + includeInlayParameterNameHints = "all", -- 'none' | 'literals' | 'all' + includeInlayParameterNameHintsWhenArgumentMatchesName = false, + includeInlayVariableTypeHints = true, + includeInlayFunctionParameterTypeHints = true, + includeInlayVariableTypeHintsWhenTypeMatchesName = false, + includeInlayPropertyDeclarationTypeHints = true, + includeInlayFunctionLikeReturnTypeHints = true, + includeInlayEnumMemberValueHints = true, + }, + }, + } +}) diff --git a/lua/config/plugins/lsp_diagnostic.lua b/lua/config/plugins/lsp_diagnostic.lua new file mode 100644 index 0000000..641635e --- /dev/null +++ b/lua/config/plugins/lsp_diagnostic.lua @@ -0,0 +1,5 @@ +local signs = { Error = " ", Warn = " ", Hint = "󱩎 ", Info = " " } +for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) +end diff --git a/lua/config/plugins/lualine.lua b/lua/config/plugins/lualine.lua new file mode 100644 index 0000000..b2b1072 --- /dev/null +++ b/lua/config/plugins/lualine.lua @@ -0,0 +1,59 @@ +require("lualine").setup({ + options = { + icons_enabled = true, + theme = 'auto', + component_separators = { left = '', right = ''}, + section_separators = { left = '', right = ''}, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + always_show_tabline = true, + globalstatus = true, + refresh = { + statusline = 100, + tabline = 100, + winbar = 100, + } + }, + sections = { + lualine_a = { + { + function() + return "  " + end, + padding = { left = 0, right = 0 }, + color = {}, + cond = nil, + }, + }, + lualine_b = {'branch'}, + lualine_c = {'diff'}, + lualine_x = {'encoding', 'filetype', 'diagnostics', 'lsp'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = { + { + function() + return "  " + end, + padding = { left = 0, right = 0 }, + color = {}, + cond = nil, + }, + }, + lualine_b = {'branch'}, + lualine_c = {'diff'}, + lualine_x = {'encoding', 'filetype', 'diagnostics', 'lsp'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {} +}) diff --git a/lua/config/plugins/luasnip.lua b/lua/config/plugins/luasnip.lua new file mode 100644 index 0000000..18a6094 --- /dev/null +++ b/lua/config/plugins/luasnip.lua @@ -0,0 +1,22 @@ +-- vscode format +require("luasnip.loaders.from_vscode").lazy_load { exclude = vim.g.vscode_snippets_exclude or {} } +require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.vscode_snippets_path or "" } + +-- snipmate format +require("luasnip.loaders.from_snipmate").load() +require("luasnip.loaders.from_snipmate").lazy_load { paths = vim.g.snipmate_snippets_path or "" } + +-- lua format +require("luasnip.loaders.from_lua").load() +require("luasnip.loaders.from_lua").lazy_load { paths = vim.g.lua_snippets_path or "" } + +vim.api.nvim_create_autocmd("InsertLeave", { + callback = function() + if + require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()] + and not require("luasnip").session.jump_active + then + require("luasnip").unlink_current() + end + end, +}) diff --git a/lua/config/plugins/navic.lua b/lua/config/plugins/navic.lua new file mode 100644 index 0000000..44b6c4f --- /dev/null +++ b/lua/config/plugins/navic.lua @@ -0,0 +1,47 @@ +local navic = require("nvim-navic") + +navic.setup { + icons = { + File = "󰈙 ", + Module = " ", + Namespace = "󰌗 ", + Package = " ", + Class = "󰌗 ", + Method = "󰆧 ", + Property = " ", + Field = " ", + Constructor = " ", + Enum = "󰕘", + Interface = "󰕘", + Function = "󰊕 ", + Variable = "󰆧 ", + Constant = "󰏿 ", + String = "󰀬 ", + Number = "󰎠 ", + Boolean = "◩ ", + Array = "󰅪 ", + Object = "󰅩 ", + Key = "󰌋 ", + Null = "󰟢 ", + EnumMember = " ", + Struct = "󰌗 ", + Event = " ", + Operator = "󰆕 ", + TypeParameter = "󰊄 ", + }, + lsp = { + auto_attach = true, + preference = nil, + }, + highlight = true, + seperator = ' ', + depth_limit = 0, + depth_limit_indicator = "..", + safe_output = true, + lazy_update_context = false, + click = false, + format_text = function(text) + return text + end, +} + diff --git a/lua/config/plugins/neotree.lua b/lua/config/plugins/neotree.lua new file mode 100644 index 0000000..e54cc91 --- /dev/null +++ b/lua/config/plugins/neotree.lua @@ -0,0 +1,52 @@ +vim.fn.sign_define("LspDiagnosticsSignError", + {text = "󰅙 ", texthl = "LspDiagnosticsSignError"}) +vim.fn.sign_define("LspDiagnosticsSignWarning", + {text = "󱇎 ", texthl = "LspDiagnosticsSignWarning"}) +vim.fn.sign_define("LspDiagnosticsSignInformation", + {text = "󰰄 ", texthl = "LspDiagnosticsSignInformation"}) +vim.fn.sign_define("LspDiagnosticsSignHint", + {text = "󰐗 ", texthl = "LspDiagnosticsSignHint"}) + +require("neo-tree").setup({ + close_if_last_window = false, + popup_border_style = "rounded", + enable_git_status = true, + enable_diagnostics = true, + open_files_do_not_replace_types = { "terminal", "trouble", "qf" }, + sort_case_insensitive = false, + sort_function = nil , + default_component_configs = { + indent = { + with_expanders = true, + }, + icon = { + folder_closed = "󰉋", + folder_open = "󰝰", + folder_empty = "󰉖", + default = "*", + highlight = "NeoTreeFileIcon" + }, + modified = { + symbol = "󰧞", + highlight = "NeoTreeModified", + }, + name = { + trailing_slash = false, + use_git_status_colors = true, + highlight = "NeoTreeFileName", + }, + git_status = { + symbols = { + added = "󰜄", + modified = "󰑕", + deleted = "󰅗", + renamed = "󰛂", + untracked = "󰞋", + ignored = "󰿠", + unstaged = "󰄱", + staged = "󰄵", + conflict = "", + } + }, + }, +}) diff --git a/lua/config/plugins/noice.lua b/lua/config/plugins/noice.lua new file mode 100644 index 0000000..273c6c1 --- /dev/null +++ b/lua/config/plugins/noice.lua @@ -0,0 +1,15 @@ +require("noice").setup({ + lsp = { + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, -- requires hrsh7th/nvim-cmp + }, + }, + presets = { + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, +}) diff --git a/lua/config/plugins/prettier.lua b/lua/config/plugins/prettier.lua new file mode 100644 index 0000000..e039edd --- /dev/null +++ b/lua/config/plugins/prettier.lua @@ -0,0 +1,19 @@ +local prettier = require("prettier") + +prettier.setup({ + bin = 'prettier', + filetypes = { + "css", + "graphql", + "html", + "javascript", + "javascriptreact", + "json", + "less", + "markdown", + "scss", + "typescript", + "typescriptreact", + "yaml", + }, +}) diff --git a/lua/config/plugins/rustaceanvim.lua b/lua/config/plugins/rustaceanvim.lua new file mode 100644 index 0000000..39a07a4 --- /dev/null +++ b/lua/config/plugins/rustaceanvim.lua @@ -0,0 +1,37 @@ +local navic = require("nvim-navic") + +vim.g.rustaceanvim = { + tools = { + autoSetHints = true, + inlay_hints = { + show_parameter_hints = true, + parameter_hints_prefix = "in: ", -- "<- " + other_hints_prefix = "out: " -- "=> " + } + }, + server = { + on_attach = function(client, bufnr) + navic.attach(client, bufnr) + end, + settings = { + ['rust-analyzer'] = { + assist = { + importEnforceGranularity = true, + importPrefix = "create" + }, + cargo = { allFeatures = true }, + checkOnSave = { + -- default: `cargo check` + command = "clippy", + allFeatures = true + }, + inlayHints = { + lifetimeElisionHints = { + enable = true, + useParameterNames = true + } + } + } + } + } +} diff --git a/lua/config/plugins/treesitter.lua b/lua/config/plugins/treesitter.lua new file mode 100644 index 0000000..92837bf --- /dev/null +++ b/lua/config/plugins/treesitter.lua @@ -0,0 +1,8 @@ +require'nvim-treesitter.configs'.setup { + ensure_installed = { 'rust', 'c', 'lua', 'tsx', 'javascript', 'typescript' }, + sync_install = false, + auto_install = true, + highlight = { + enable = true, + } +} diff --git a/lua/config/utils/bufferline.lua b/lua/config/utils/bufferline.lua new file mode 100644 index 0000000..80caae6 --- /dev/null +++ b/lua/config/utils/bufferline.lua @@ -0,0 +1,95 @@ +local Utils = {} + +function Utils.is_ft(b, ft) + return vim.bo[b].filetype == ft +end + +function Utils.custom_filter(buf, buf_nums) + local logs = vim.tbl_filter(function(b) + return Utils.is_ft(b, "log") + end, buf_nums or {}) + if vim.tbl_isempty(logs) then + return true + end + local tab_num = vim.fn.tabpagenr() + local last_tab = vim.fn.tabpagenr "$" + local is_log = Utils.is_ft(buf, "log") + if last_tab == 1 then + return true + end + -- only show log buffers in secondary tabs + return (tab_num == last_tab and is_log) or (tab_num ~= last_tab and not is_log) +end + +function Utils.buf_kill(kill_command, bufnr, force) + local bo = vim.bo + local api = vim.api + local fmt = string.format + local fn = vim.fn + + if bufnr == 0 or bufnr == nil then + bufnr = api.nvim_get_current_buf() + end + + local bufname = api.nvim_buf_get_name(bufnr) + + if not force then + local choice + if bo[bufnr].modified then + choice = fn.confirm(fmt([[Save changes to "%s"?]], bufname), "&Yes\n&No\n&Cancel") + if choice == 1 then + vim.api.nvim_buf_call(bufnr, function() + vim.cmd("w") + end) + elseif choice == 2 then + force = true + else + return + end + elseif api.nvim_get_option_value("buftype", { buf = 0 }) == "terminal" then + choice = fn.confirm(fmt([[Close "%s"?]], bufname), "&Yes\n&No\n&Cancel") + if choice == 1 then + force = true + else + return + end + end + end + + -- Get list of windows IDs with the buffer to close + local windows = vim.tbl_filter(function(win) + return api.nvim_win_get_buf(win) == bufnr + end, api.nvim_list_wins()) + + if force then + kill_command = kill_command .. "!" + end + + -- Get list of active buffers + local buffers = vim.tbl_filter(function(buf) + return api.nvim_buf_is_valid(buf) and bo[buf].buflisted + end, api.nvim_list_bufs()) + + -- If there is only one buffer (which has to be the current one), vim will + -- create a new buffer on :bd. + -- For more than one buffer, pick the previous buffer (wrapping around if necessary) + if #buffers > 1 and #windows > 0 then + for i, v in ipairs(buffers) do + if v == bufnr then + local prev_buf_idx = i == 1 and #buffers or (i - 1) + local prev_buffer = buffers[prev_buf_idx] + for _, win in ipairs(windows) do + api.nvim_win_set_buf(win, prev_buffer) + end + end + end + end + + -- Check if buffer still exists, to ensure the target buffer wasn't killed + -- due to options like bufhidden=wipe. + if api.nvim_buf_is_valid(bufnr) and bo[bufnr].buflisted then + vim.cmd(string.format("%s %d", kill_command, bufnr)) + end +end + +return Utils diff --git a/lua/mappings.lua b/lua/mappings.lua new file mode 100644 index 0000000..22171e9 --- /dev/null +++ b/lua/mappings.lua @@ -0,0 +1,73 @@ +local map = vim.keymap.set +local bl_utils = require("config.utils.bufferline") +local hover = require "hover" + +map("n", ";", ":", { desc = "CMD enter command mode" }) + +map("i", "", "", { desc = "move left" }) +map("i", "", "", { desc = "move right" }) +map("i", "", "", { desc = "move down" }) +map("i", "", "", { desc = "move up" }) + +map("n", "", "h", { desc = "switch window left" }) +map("n", "", "l", { desc = "switch window right" }) +map("n", "", "j", { desc = "switch window down" }) +map("n", "", "k", { desc = "switch window up" }) + +map("n", "", "NeoTreeShowToggle", { desc = "nvimtree toggle window" }) + +map("n", "", "BufferLineMoveNext", { desc = "move buffer to right" }) +map("n", "", "BufferLineMovePrev", { desc = "move buffer to left" }) +map("n", "", "BufferLineCycleNext", { desc = "switch to next buffer" }) +map("n", "", "BufferLineCyclePrev", { desc = "switch to prev buffer" }) + +map("n", "", "DapContinue") +map("n", "", "DapToggleBreakpoint") + +map("n", "mk", "RustLsp moveItem upcr>") +map("n", "m,", "RustLsp moveItem down") +map("n", "rs", "RustLsp run") +map("n", "ca", "RustLsp codeAction") +map("n", "", "w!") +map("i", "", "w!") + +map("n", "<", "") +map("n", ">", ">gv") + +map("n", "c", function(bufnr) + bl_utils.buf_kill("bd", bufnr, true) +end) + +map("n", "dr", " DapContinue ", { desc = "Continue debug" }) + +map("n", "do", function() + require("dapui").open() +end, { desc = "Open DAP ui" }) +map("n", "dc", function() + require("dapui").close() +end, { desc = "Start or continue debug" }) +map("n", "dt", function() + require("dapui").toggle() +end, { desc = "Toggle DAP ui" }) + +map("n", "", "m .+1==") +map("n", "", "m .-2==") +map("i", "", "m .+1==gi") +map("i", "", "m .-2==gi") + +map("n", "", "resize -2") +map("n", "", "resize +2") +map("n", "", "vertical resize -2") +map("n", "", "vertical resize +2") + +map("n", "an", "set norelativenumber") +map("n", "rn", "set relativenumber") +map("n", "tt", "ToggleTerm") +map("n", "", "foldopen") +map("n", "", "foldclose") + +map("n", "hh", hover.hover) +map("n", "hs", hover.hover_select) + +map("n", "vs", " vsplit ") +map("n", "ss", " split ") diff --git a/lua/plugins/core/init.lua b/lua/plugins/core/init.lua new file mode 100644 index 0000000..12b36f5 --- /dev/null +++ b/lua/plugins/core/init.lua @@ -0,0 +1,152 @@ +return { + { + 'simrat39/inlay-hints.nvim', + }, + { + "LunarVim/breadcrumbs.nvim", + }, + { + "akinsho/bufferline.nvim", + }, + { + "lewis6991/gitsigns.nvim" + }, + { + "lewis6991/hover.nvim", + }, + { + "nvim-lualine/lualine.nvim", + }, + { + "akinsho/toggleterm.nvim", + }, + { + "windwp/nvim-autopairs", + }, + { + 'kevinhwang91/promise-async', + }, + { + 'theHamsta/nvim-dap-virtual-text', + }, + { + "hrsh7th/cmp-nvim-lsp", + }, + { + "SmiteshP/nvim-navic", + }, + { + "kyazdani42/nvim-web-devicons" + }, + { + 'NvChad/nvim-colorizer.lua', + }, + { + 'numToStr/Comment.nvim' + }, + { + "nvim-treesitter/nvim-treesitter", + }, + { + "catppuccin/nvim" + }, + { + "vague2k/huez.nvim", + }, + { + "nvim-telescope/telescope.nvim", + }, + { + "williamboman/mason-lspconfig.nvim", + }, + { + "neovim/nvim-lspconfig", + }, + { + "mfussenegger/nvim-dap", + event = "VeryLazy", + }, + { + "L3MON4D3/LuaSnip", + lazy = true, + }, + { + 'folke/lazydev.nvim', + ft = "lua", + }, + { + 'Bekaboo/dropbar.nvim', + dependencies = { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'make' + }, + config = function() + local dropbar_api = require('dropbar.api') + vim.keymap.set('n', ';', dropbar_api.pick, { desc = 'Pick symbols in winbar' }) + vim.keymap.set('n', '[;', dropbar_api.goto_context_start, { desc = 'Go to start of current context' }) + vim.keymap.set('n', '];', dropbar_api.select_next_context, { desc = 'Select next context' }) + end + }, + { + "folke/noice.nvim", + event = "VeryLazy", + dependencies = { + "MunifTanjim/nui.nvim", + "rcarriga/nvim-notify", + }, + }, + { + "nvim-neo-tree/neo-tree.nvim", + branch = "v2.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + }, + { + "williamboman/mason.nvim", + opts = { + ensure_installed = { + "eslint-lsp", + "js-debug-adapter", + "prettier", + "tinymist", + "typescript-language-server", + } + } + }, + { + "rcarriga/nvim-dap-ui", + dependencies = { + "nvim-neotest/nvim-nio", + "mfussenegger/nvim-dap", + }, + event = "VeryLazy", + config = function() + require("dapui").setup() + end + }, + { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + { + "L3MON4D3/LuaSnip", + dependencies = "rafamadriz/friendly-snippets", + opts = { history = true, updateevents = "TextChanged,TextChangedI" }, + config = function(_, opts) + require("luasnip").config.set_config(opts) + require "config.plugins.luasnip" + end, + }, + { + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + }, + }, + }, +} diff --git a/lua/plugins/secondary/init.lua b/lua/plugins/secondary/init.lua new file mode 100644 index 0000000..bf05bfc --- /dev/null +++ b/lua/plugins/secondary/init.lua @@ -0,0 +1,50 @@ +return { + { + 'nvimdev/dashboard-nvim', + event = 'VimEnter', + dependencies = { { 'nvim-tree/nvim-web-devicons' } } + }, + { + "kaarmu/typst.vim", + lazy = true, + }, + { + 'MunifTanjim/prettier.nvim', + lazy = true, + }, + { + "savq/melange-nvim" + }, + { + "mlaursen/vim-react-snippets", + lazy = true, + }, + { + "windwp/nvim-ts-autotag", + lazy = true, + }, + { + "lukas-reineke/indent-blankline.nvim" + }, + { + "mxsdev/nvim-dap-vscode-js", + lazy = true, + }, + { + "windwp/nvim-autopairs", + lazy = true, + event = "InsertEnter", + config = true + }, + { + "microsoft/vscode-js-debug", + lazy = true, + build = "npm install --legacy-peer-deps && npx gulp vsDebugServerBundle && mv dist out" + }, + { + "mrcjkb/rustaceanvim", + version = '^4', -- Recommended + lazy = false, -- This plugin is already lazy + ft = { "rust" }, + }, +}