From 64571f1e4c274bf926df122d624097cf2c24fe57 Mon Sep 17 00:00:00 2001 From: Sojus07 Date: Wed, 12 Feb 2025 21:08:09 +0100 Subject: [PATCH] kekl --- init.lua | 18 ++++ lazy-lock.json | 28 ++++++ lua/core/opts.lua | 40 +++++++++ lua/plugins/cmp.lua | 99 +++++++++++++++++++++ lua/plugins/default.lua | 91 ++++++++++++++++++++ lua/plugins/lsp.lua | 45 ++++++++++ lua/plugins/lualine.lua | 48 +++++++++++ lua/plugins/neotree.lua | 186 ++++++++++++++++++++++++++++++++++++++++ lua/plugins/rust.lua | 14 +++ 9 files changed, 569 insertions(+) create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/core/opts.lua create mode 100644 lua/plugins/cmp.lua create mode 100644 lua/plugins/default.lua create mode 100644 lua/plugins/lsp.lua create mode 100644 lua/plugins/lualine.lua create mode 100644 lua/plugins/neotree.lua create mode 100644 lua/plugins/rust.lua diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..4658f57 --- /dev/null +++ b/init.lua @@ -0,0 +1,18 @@ +require('core.opts') +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +require('lazy').setup({ + { import = "plugins" } +}) + diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..7c6b9fe --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,28 @@ +{ + "LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" }, + "alpha-nvim": { "branch": "main", "commit": "de72250e054e5e691b9736ee30db72c65d560771" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-calc": { "branch": "main", "commit": "5947b412da67306c5b68698a02a846760059be2e" }, + "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, + "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "crates.nvim": { "branch": "main", "commit": "1c924d5a9ea3496c4e1a02d0d51388ba809f8468" }, + "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }, + "lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" }, + "lualine.nvim": { "branch": "master", "commit": "f4f791f67e70d378a754d02da068231d2352e5bc" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "f75e877f5266e87523eb5a18fcde2081820d087b" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "5d172e8315444dbc32867d1c7b04d8e7e68ec4e1" }, + "neocord": { "branch": "main", "commit": "4d55d8dab2d5f2f272192add7a2c21982039c699" }, + "nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" }, + "nvim-autopairs": { "branch": "master", "commit": "3d02855468f94bf435db41b661b58ec4f48a06b7" }, + "nvim-cmp": { "branch": "main", "commit": "12509903a5723a876abd65953109f926f4634c30" }, + "nvim-lspconfig": { "branch": "master", "commit": "6c17f8656f667727b27f5f598463afedb7791b18" }, + "nvim-web-devicons": { "branch": "master", "commit": "402377242b04be3f4f0f3720bd952df86e946c30" }, + "oxocarbon.nvim": { "branch": "main", "commit": "004777819ba294423b638a35a75c9f0c7be758ed" }, + "plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" }, + "rustaceanvim": { "branch": "master", "commit": "f03035fa03ccb36cd26d0792c946fbacba1d1a39" }, + "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" } +} diff --git a/lua/core/opts.lua b/lua/core/opts.lua new file mode 100644 index 0000000..1f19aaa --- /dev/null +++ b/lua/core/opts.lua @@ -0,0 +1,40 @@ +vim.opt.shiftwidth = 2 +vim.opt.tabstop = 2 +vim.opt.softtabstop = 2 +vim.opt.cursorline = true +vim.opt.cursorcolumn = true +vim.opt.expandtab = true +vim.opt.autoindent = true +vim.opt.smartindent = true +vim.opt.relativenumber = true + +vim.diagnostic.config({ + virtual_text = true, + virtual_lines = true, +}) + +local map = vim.api.nvim_set_keymap +local opts = { noremap = true, silent = true } + +vim.g.mapleader = "\\" +map('n', '', ":ToggleTerm size=15", opts) +map('n', '', ":Neotree filesystem reveal toggle", opts) +map('v', '', '>gv', opts) +map('v', '', 'ff', 'Telescope find_files', opts) +map('n', 'gs', 'Telescope grep_string', opts) + +vim.cmd [[ + set nobackup + cnoreabbrev W! w! + cnoreabbrev Q! q! + cnoreabbrev Qall! qall! + cnoreabbrev Wq wq + cnoreabbrev Wa wa + cnoreabbrev wQ wq + cnoreabbrev WQ wq + cnoreabbrev W w + cnoreabbrev Q q + cnoreabbrev Qall qall +]] + diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..7fcbfa6 --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,99 @@ +return { + { + "hrsh7th/nvim-cmp", + dependencies = { + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-cmdline', + 'hrsh7th/cmp-nvim-lua', + 'hrsh7th/cmp-calc', + 'saadparwaiz1/cmp_luasnip', + 'L3MON4D3/LuaSnip', + 'onsails/lspkind.nvim', + { + 'windwp/nvim-autopairs', + event = "InsertEnter", + config = true + }, + }, + config = function() + local cmp = require("cmp") + local lspkind = require("lspkind") + + vim.opt.completeopt = { "menu", "menuone", "noinsert", "noselect" } + + cmp.setup({ + formatting = { + format = function(entry, vim_item) + vim_item.menu = ({ + nvim_lsp = "[LSP]", + buffer = "[BUF]", + path = "[PATH]", + luasnip = "[SNIP]", + nvim_lua = "[LUA]", + })[entry.source.name] + + vim_item.kind = lspkind.symbolic(vim_item.kind, { mode = "symbol" }) + return vim_item + end, + }, + sorting = { + comparators = { + cmp.config.compare.offset, + cmp.config.compare.exact, + cmp.config.compare.recently_used, + cmp.config.compare.kind, + cmp.config.compare.sort_text, + cmp.config.compare.length, + cmp.config.compare.order, + }, + }, + window = { + completion = { + autocomplete = true, + col_offset = -3, + side_padding = 0, + }, + completion = cmp.config.window.bordered({ + winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None", + }), + documentation = cmp.config.window.bordered({ + winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None", + }), + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end, { "i", "s" }), + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end, { "i", "s" }), + + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = false }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'buffer' }, + { name = 'path' }, + { name = 'nvim_lua' }, + }), + }) + end + }, +} diff --git a/lua/plugins/default.lua b/lua/plugins/default.lua new file mode 100644 index 0000000..e7ed039 --- /dev/null +++ b/lua/plugins/default.lua @@ -0,0 +1,91 @@ +return { + { + "nyoom-engineering/oxocarbon.nvim", + config = function() + vim.cmd[[colorscheme oxocarbon]] + end + }, + { + 'goolord/alpha-nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function () + 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("r", " Open Repo", ":cd ~/repos"), + dashboard.button("t", " Terminal", ":ToggleTerm size=40 direction=float"), + dashboard.button("c", " Configuration", ":e ~/.config/nvim/"), + dashboard.button("q", "󰈆 Quit Neovim", ":qa"), + } + + local function footer() + local text = { + "Imagine using Windows/MacOS", + "i use neovim, you see?", + "Rust programmer: Rewrite whole universe in Rust", + "Rust programmer just using Rust cuz C skill issue's", + "best shitty lua guy", + "Imagine 2 Onion's. Heck imagine 3 Onion's", + "i have Autism", + "我的地下室里有孩子", + } + + math.randomseed(os.time()) + local randomtext = math.random(#text) + return text[randomtext] + 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 + alpha.setup(dashboard.opts) + end + }, + { + "IogaMaster/neocord", + config = function () + require("neocord").setup({ + logo = "auto", + logo_tooltip = nil, + main_image = "language", + client_id = "1157438221865717891", + log_level = nil, + debounce_timeout = 10, + blacklist = {}, + file_assets = {}, + show_time = true, + global_timer = true, + editing_text = "Editing %s", + file_explorer_text = "Browsing %s", + git_commit_text = "Committing changes", + plugin_manager_text = "Managing plugins", + reading_text = "Reading %s", + workspace_text = "Working on %s", + terminal_text = "Using Terminal", + }) + end + }, + +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..0cd18bb --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,45 @@ +return { + { + "williamboman/mason.nvim", + config = function() + require("mason").setup() + end + }, + { + "williamboman/mason-lspconfig.nvim", + dependencies = { "neovim/nvim-lspconfig" }, + config = function() + require("mason-lspconfig").setup { + ensure_installed = { "gopls", "pyright", "clangd", "lua_ls" } + } + end + }, + { + "neovim/nvim-lspconfig", + config = function() + local lspconfig = require("lspconfig") + local capabilities = require('cmp_nvim_lsp').default_capabilities() + + lspconfig.gopls.setup {} + lspconfig.pyright.setup {} + lspconfig.clangd.setup {} + lspconfig.lua_ls.setup {} + vim.g.rustaceanvim = { + server = { + cmd = function() + local mason_registry = require('mason-registry') + if mason_registry.is_installed('rust-analyzer') then + local ra = mason_registry.get_package('rust-analyzer') + local ra_filename = ra:get_receipt():get().links.bin['rust-analyzer'] + return { ('%s/%s'):format(ra:get_install_path(), ra_filename or 'rust-analyzer') } + else + return { 'rust-analyzer' } + end + end, + }, + } + end + } +} + + diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..3b9c992 --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,48 @@ +return { + { + "nvim-lualine/lualine.nvim", + config = function() + 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, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + } + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch', 'diff', 'diagnostics' }, + lualine_c = { 'filename' }, + lualine_x = { 'encoding', 'fileformat', 'filetype' }, + lualine_y = { 'progress' }, + lualine_z = { 'location' } + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { 'filename' }, + lualine_x = { 'location' }, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {} + } + end + }, +} + diff --git a/lua/plugins/neotree.lua b/lua/plugins/neotree.lua new file mode 100644 index 0000000..eeeadd1 --- /dev/null +++ b/lua/plugins/neotree.lua @@ -0,0 +1,186 @@ +return { + { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + { + 'akinsho/toggleterm.nvim', + version = "*", + config = function() + require("toggleterm").setup() + end + }, + }, + config = function () + vim.fn.sign_define("DiagnosticSignError", { text = " ", texthl = "DiagnosticSignError" }) + vim.fn.sign_define("DiagnosticSignWarn", { text = " ", texthl = "DiagnosticSignWarn" }) + vim.fn.sign_define("DiagnosticSignInfo", { text = " ", texthl = "DiagnosticSignInfo" }) + vim.fn.sign_define("DiagnosticSignHint", { text = "󰌵", texthl = "DiagnosticSignHint" }) + + require("neo-tree").setup({ + close_if_last_window = true, + 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 = { + container = { + enable_character_fade = true + }, + indent = { + indent_size = 2, + padding = 1, + with_markers = true, + indent_marker = "│", + last_indent_marker = "└", + highlight = "NeoTreeIndentMarker", + with_expanders = nil, + expander_collapsed = "", + expander_expanded = "", + expander_highlight = "NeoTreeExpander", + }, + 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 = "", + } + }, + file_size = { + enabled = true, + required_width = 64, + }, + type = { + enabled = true, + required_width = 122, + }, + last_modified = { + enabled = true, + required_width = 88, + }, + created = { + enabled = true, + required_width = 110, + }, + symlink_target = { + enabled = false, + }, + }, + commands = {}, + window = { + position = "left", + width = 30, + mapping_options = { + noremap = true, + nowait = true, + }, + mappings = { + [""] = { "toggle_node", nowait = false }, + ["<2-LeftMouse>"] = "open", + [""] = "open", + [""] = "cancel", + ["p"] = { "toggle_preview", config = { use_float = true, use_image_nvim = true } }, + ["a"] = { "add", config = { show_path = "none" } }, + ["A"] = "add_directory", + ["d"] = "delete", + ["r"] = "rename", + ["y"] = "copy_to_clipboard", + ["x"] = "cut_to_clipboard", + ["p"] = "paste_from_clipboard", + ["c"] = "copy", + ["m"] = "move", + ["q"] = "close_window", + ["R"] = "refresh", + } + }, + nesting_rules = {}, + filesystem = { + filtered_items = { + visible = false, + hide_dotfiles = true, + hide_gitignored = true, + hide_hidden = true, + hide_by_name = {}, + hide_by_pattern = {}, + always_show = {}, + never_show = {}, + never_show_by_pattern = {}, + }, + follow_current_file = { + enabled = true, + leave_dirs_open = false, + }, + group_empty_dirs = false, + hijack_netrw_behavior = "open_default", + use_libuv_file_watcher = false, + window = { + mappings = { + [""] = "navigate_up", + ["."] = "set_root", + [""] = "toggle_hidden", + } + }, + commands = {} + }, + buffers = { + follow_current_file = { + enabled = true, + leave_dirs_open = false, + }, + group_empty_dirs = true, + show_unloaded = true, + }, + git_status = { + window = { + position = "float", + mappings = { + ["A"] = "git_add_all", + ["gu"] = "git_unstage_file", + ["ga"] = "git_add_file", + ["gr"] = "git_revert_file", + ["gc"] = "git_commit", + ["gp"] = "git_push", + ["gg"] = "git_commit_and_push", + ["o"] = { "show_help", nowait = false, config = { title = "Order by", prefix_key = "o" }}, + ["oc"] = { "order_by_created", nowait = false }, + ["od"] = { "order_by_diagnostics", nowait = false }, + ["om"] = { "order_by_modified", nowait = false }, + ["on"] = { "order_by_name", nowait = false }, + ["os"] = { "order_by_size", nowait = false }, + ["ot"] = { "order_by_type", nowait = false }, + } + } + } + }) + vim.cmd([[nnoremap \ :Neotree reveal]]) + end + }, +} + diff --git a/lua/plugins/rust.lua b/lua/plugins/rust.lua new file mode 100644 index 0000000..c01152a --- /dev/null +++ b/lua/plugins/rust.lua @@ -0,0 +1,14 @@ +return { + { + 'mrcjkb/rustaceanvim', + version = '^5', + lazy = false, + }, + { + 'saecki/crates.nvim', + tag = 'stable', + config = function() + require('crates').setup() + end, + }, +}