From 930c835e603f825e63746e06f92ec69e07958bdc Mon Sep 17 00:00:00 2001 From: Rendo Date: Mon, 9 Mar 2026 21:13:27 +0500 Subject: [PATCH] Initial commit --- init.lua | 82 +++++++++++++++++++++++++++++++++++++++ lazy-lock.json | 9 +++++ lua/config/lazy.lua | 35 +++++++++++++++++ lua/plugins.lua | 94 +++++++++++++++++++++++++++++++++++++++++++++ search.lua | 3 ++ 5 files changed, 223 insertions(+) create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/config/lazy.lua create mode 100644 lua/plugins.lua create mode 100644 search.lua diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..11e310d --- /dev/null +++ b/init.lua @@ -0,0 +1,82 @@ +require("config.lazy") +require("lazy").setup("plugins") + +local opt = vim.opt + +opt.number = true + +vim.cmd("colorscheme unokai") +opt.smartindent= true +opt.clipboard='unnamedplus' + +opt.tabstop = 4 +opt.shiftwidth = 4 + +opt.ignorecase = true +opt.smartcase = true + +opt.linebreak = true +opt.showbreak = "—>" + +opt.mouse = "n" +opt.mousemodel = "popup" +opt.mousescroll = {"ver:1", "hor:0"} + +vim.lsp.config('lua_ls', { + on_init = function(client) + if client.workspace_folders then + local path = client.workspace_folders[1].name + if + path ~= vim.fn.stdpath('config') + and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) + then + return + end + end + + client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { + runtime = { + -- Tell the language server which version of Lua you're using (most + -- likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + -- Tell the language server how to find Lua modules same way as Neovim + -- (see `:h lua-module-load`) + path = { + 'lua/?.lua', + 'lua/?/init.lua', + }, + }, + -- Make the server aware of Neovim runtime files + workspace = { + checkThirdParty = false, + library = { + vim.env.VIMRUNTIME, + -- Depending on the usage, you might want to add additional paths + -- here. + -- '${3rd}/luv/library', + -- '${3rd}/busted/library', + }, + -- Or pull in all of 'runtimepath'. + -- NOTE: this is a lot slower and will cause issues when working on + -- your own configuration. + -- See https://github.com/neovim/nvim-lspconfig/issues/3189 + -- library = vim.api.nvim_get_runtime_file('', true), + }, + }) + end, + settings = { + Lua = {}, + }, +}) + +vim.lsp.config('rust_analyzer', { + settings = { + ['rust-analyzer'] = { + diagnostics = { + enable = false; + } + } + } +}) + +vim.lsp.enable({'clangd','lua_ls','rust_analyzer'}) diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..a50c4d7 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,9 @@ +{ + "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, + "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, + "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, + "lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" }, + "nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" }, + "nvim-lspconfig": { "branch": "master", "commit": "2163c54bb6cfec53e3e555665ada945b8c8331b9" } +} diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..f5ee74c --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,35 @@ +-- Bootstrap lazy.nvim +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) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "habamax" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..9ad9b0f --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1,94 @@ +function config_cmp() + -- Set up nvim-cmp. + local cmp = require'cmp' + + cmp.setup({ + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. + -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + -- require('snippy').expand_snippet(args.body) -- For `snippy` users. + -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. + -- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+) + + -- For `mini.snippets` users: + -- local insert = MiniSnippets.config.expand.insert or MiniSnippets.default_insert + -- insert({ body = args.body }) -- Insert at cursor + -- cmp.resubscribe({ "TextChangedI", "TextChangedP" }) + -- require("cmp.config").set_onetime({ sources = {} }) + end, + }, + window = { + -- completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'vsnip' }, -- For vsnip users. + -- { name = 'luasnip' }, -- For luasnip users. + -- { name = 'ultisnips' }, -- For ultisnips users. + -- { name = 'snippy' }, -- For snippy users. + }, { + { name = 'buffer' }, + }) + }) + + -- To use git you need to install the plugin petertriho/cmp-git and uncomment lines below + -- Set configuration for specific filetype. + --[[ cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'git' }, + }, { + { name = 'buffer' }, + }) + }) + require("cmp_git").setup() ]]-- + + -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } + }) + + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }), + matching = { disallow_symbol_nonprefix_matching = false } + }) + + -- Set up lspconfig. + local capabilities = require('cmp_nvim_lsp').default_capabilities() + -- Replace with each lsp server you've enabled. + vim.lsp.config('', { + capabilities = capabilities + }) + vim.lsp.enable('') + +end + +return { + 'neovim/nvim-lspconfig', + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-cmdline', + { + 'hrsh7th/nvim-cmp', + config = config_cmp + } +} diff --git a/search.lua b/search.lua new file mode 100644 index 0000000..ffb40a9 --- /dev/null +++ b/search.lua @@ -0,0 +1,3 @@ +vim.opt.ignorecase = true +vim.opt.smartcase = true +vim.opt.showmatch = true