From b41fbc20c2fd10d4bee01f306d41d86ac6c7f76e Mon Sep 17 00:00:00 2001 From: SL1900 Date: Wed, 22 May 2024 19:55:15 +0900 Subject: [PATCH] Initial commit --- init.lua | 114 ++++++++++++++++++++++++++ lazy-lock.json | 39 +++++++++ lua/plugins/autopairs.lua | 3 + lua/plugins/cmp.lua | 51 ++++++++++++ lua/plugins/color-theme.lua | 9 ++ lua/plugins/comment.lua | 3 + lua/plugins/distant.lua | 8 ++ lua/plugins/gitsigns.lua | 14 ++++ lua/plugins/lsp-signature.lua | 8 ++ lua/plugins/lspconfig.lua | 3 + lua/plugins/luasnip.lua | 10 +++ lua/plugins/mason.lua | 4 + lua/plugins/mini.lua | 11 +++ lua/plugins/neo-tree.lua | 21 +++++ lua/plugins/neogit.lua | 9 ++ lua/plugins/nvim-ufo.lua | 21 +++++ lua/plugins/surround.lua | 3 + lua/plugins/tailwind-css-colors.lua | 3 + lua/plugins/telescope-filebrowser.lua | 9 ++ lua/plugins/telescope.lua | 32 ++++++++ lua/plugins/treesitter-context.lua | 5 ++ lua/plugins/treesitter.lua | 12 +++ lua/plugins/trouble.lua | 8 ++ lua/plugins/web-decicons.lua | 3 + lua/plugins/which-key.lua | 17 ++++ options.lua | 51 ++++++++++++ remap.lua | 63 ++++++++++++++ 27 files changed, 534 insertions(+) create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/plugins/autopairs.lua create mode 100644 lua/plugins/cmp.lua create mode 100644 lua/plugins/color-theme.lua create mode 100644 lua/plugins/comment.lua create mode 100644 lua/plugins/distant.lua create mode 100644 lua/plugins/gitsigns.lua create mode 100644 lua/plugins/lsp-signature.lua create mode 100644 lua/plugins/lspconfig.lua create mode 100644 lua/plugins/luasnip.lua create mode 100644 lua/plugins/mason.lua create mode 100644 lua/plugins/mini.lua create mode 100644 lua/plugins/neo-tree.lua create mode 100644 lua/plugins/neogit.lua create mode 100644 lua/plugins/nvim-ufo.lua create mode 100644 lua/plugins/surround.lua create mode 100644 lua/plugins/tailwind-css-colors.lua create mode 100644 lua/plugins/telescope-filebrowser.lua create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/treesitter-context.lua create mode 100644 lua/plugins/treesitter.lua create mode 100644 lua/plugins/trouble.lua create mode 100644 lua/plugins/web-decicons.lua create mode 100644 lua/plugins/which-key.lua create mode 100644 options.lua create mode 100644 remap.lua diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..859d833 --- /dev/null +++ b/init.lua @@ -0,0 +1,114 @@ +package.path = vim.fn.expand("$XDG_CONFIG_HOME") .. "\\nvim\\?.lua;" .. package.path + +vim.api.nvim_exec("language en_US", true) + +local lazypath = vim.fn.expand("$XDG_CONFIG_HOME") .. "\\nvim\\lazy\\lazy.nvim" + +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +--Insure lazy.nvim is installed +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", + lazypath + }) +end +vim.opt.rtp:prepend(lazypath) + +local lazy_options = { + root = vim.fn.expand("$XDG_CONFIG_HOME") .. "\\nvim\\plugins\\lazy\\", + install = { + missing = true, + -- colorscheme = { "habamax" } + } +} + +require("options") +require("lazy").setup("plugins", lazy_options) +require("remap") + +-- LSP +local lsp_servers = require("mason-lspconfig").get_installed_servers() +local capabilities = require("cmp_nvim_lsp").default_capabilities() +capabilities.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true +} +for _, server in pairs(lsp_servers) do + if server == "lua_ls" then + require("lspconfig")[server].setup({ + capabilities = capabilities, + settings = { + Lua = { diagnostics = { globals = { "vim" } } } + } + }) + elseif server == "svelte" then + local dyn_cap = vim.lsp.protocol.make_client_capabilities() + dyn_cap.workspace.didChangeWatchedFiles.dynamicRegistration = true + dyn_cap.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true + } + + require("lspconfig")[server].setup({ + capabilities = dyn_cap, + on_attach = function(client) + vim.api.nvim_create_autocmd("BufWritePost", { + pattern = { "*.js", "*.ts" }, + callback = function(ctx) + client.notify("$/onDidChangeTsOrJsFile", { uri = ctx.match }) + end + }) + end, + settings = { + svelte = { plugin = { svelte = { compilerWarnings = { + ["a11y-no-onchange"] = "ignore", + ["a11y-aria-attributes"] = "ignore", + ["a11y-no-static-element-interactions"] = "ignore", + ["a11y-click-events-have-key-events"] = "ignore", + }}}} + } + }) + else + require("lspconfig")[server].setup({ capabilities = capabilities }) + end +end + +vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("LspConfig", {}), + callback = function(ev) + vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc" + print("lsp_attach callback") + + local opts = { buffer = ev.buf } + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) + vim.keymap.set("n", "", vim.lsp.buf.signature_help, opts) + vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set("n", "wi", vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set("n", "wl", function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, opts) + vim.keymap.set("n", "D", vim.lsp.buf.type_definition, opts) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) + vim.keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) + vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) + vim.keymap.set("n", "f", function() + vim.lsp.buf.format { async = true } + end, opts) + end +}) + +--Color +local color = nil +-- vim.cmd.colorscheme(color or "rose-pine") +-- vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) +-- vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) + diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..003bb46 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,39 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "LuaSnip": { "branch": "master", "commit": "de1a287c9cb525ae52bc846e8f6207e5ef1da5ac" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp-vsnip": { "branch": "main", "commit": "989a8a73c44e926199bfd05fa7a516d51f2d2752" }, + "diffview.nvim": { "branch": "main", "commit": "3dc498c9777fe79156f3d32dddd483b8b3dbd95f" }, + "distant.nvim": { "branch": "v0.3", "commit": "823267cf3b77cf9a7ae28454926eabc18fec1ba0" }, + "friendly-snippets": { "branch": "main", "commit": "dd2fd1281d4b22e7b4a5bfafa3e142d958e251f2" }, + "gitsigns.nvim": { "branch": "main", "commit": "805610a9393fa231f2c2b49cb521bfa413fadb3d" }, + "lsp_signature.nvim": { "branch": "master", "commit": "aed5d1162b0f07bb3af34bedcc5f70a2b6466ed8" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "9ae570e206360e47d30b4c35a4550c165f4ea7b7" }, + "mason.nvim": { "branch": "main", "commit": "49ff59aded1047a773670651cfa40e76e63c6377" }, + "mini.nvim": { "branch": "main", "commit": "c333187fcc76d7e772dac32c2a440a949fe34be4" }, + "neo-tree.nvim": { "branch": "main", "commit": "6e20108c4a8128782f534f5fe90c757b44212ef6" }, + "neogit": { "branch": "master", "commit": "bc0c609e3568a171e0549b449aa1b2b4b5b20e8c" }, + "neovim": { "branch": "main", "commit": "b6fe88c3282cf9f117a3e836d761c2d78d02f417" }, + "nui.nvim": { "branch": "main", "commit": "a3597dc88b53489d3fddbddbbd13787355253bb0" }, + "nvim-autopairs": { "branch": "master", "commit": "b0b79e42a28f09719a7da9534c3731fa37319d9b" }, + "nvim-cmp": { "branch": "main", "commit": "24122371810089d390847d8ba66325c1f1aa64c0" }, + "nvim-lspconfig": { "branch": "master", "commit": "cee94b22adc96582d9136f85fb3b076feda8825c" }, + "nvim-surround": { "branch": "main", "commit": "6d0dc3dbb557bcc6a024969da461df4ba803fc48" }, + "nvim-treesitter": { "branch": "master", "commit": "8012b55eee65eba1d1ee4df0a186d30e72dcbe65" }, + "nvim-treesitter-context": { "branch": "master", "commit": "7068ad6d16c682db0f6bf25f64ccfee34ec5d452" }, + "nvim-ufo": { "branch": "main", "commit": "4b4077850d1b3af09f4957b67144943cf3da401a" }, + "nvim-web-devicons": { "branch": "master", "commit": "e37bb1feee9e7320c76050a55443fa843b4b6f83" }, + "plenary.nvim": { "branch": "master", "commit": "08e301982b9a057110ede7a735dd1b5285eb341f" }, + "promise-async": { "branch": "main", "commit": "93540c168c5ed2b030ec3e6c40ab8bbb85e36355" }, + "tailwindcss-colors.nvim": { "branch": "main", "commit": "ccb5be2f84673c1a0ef90a0c0a76733e85e5265b" }, + "telescope-file-browser.nvim": { "branch": "master", "commit": "4d5fd21bae12ee6e9a79232e1c377f43c419d0c5" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "master", "commit": "52f500110bcf9190b44b4d8640162adc86772ec4" }, + "trouble.nvim": { "branch": "main", "commit": "b9cf677f20bb2faa2dacfa870b084e568dca9572" }, + "vim-vsnip": { "branch": "master", "commit": "02a8e79295c9733434aab4e0e2b8c4b7cea9f3a9" }, + "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } +} \ No newline at end of file diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua new file mode 100644 index 0000000..553eeef --- /dev/null +++ b/lua/plugins/autopairs.lua @@ -0,0 +1,3 @@ +return { + { "windwp/nvim-autopairs", event = "InsertEnter", config = true }, +} diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..5e0480a --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,51 @@ +return { + { + "hrsh7th/nvim-cmp", + config = function() + local cmp = require("cmp") + + cmp.setup({ + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end + }, + 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 }) + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "vsnip" } + }, { + { name = "buffer" } + }) + }) + + cmp.setup.cmdline({ "/", "?" }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" } + } + }) + + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" } + }, { + { name = "cmdline" } + }) + }) + end + }, + { "hrsh7th/cmp-nvim-lsp" }, + { "hrsh7th/cmp-buffer" }, + { "hrsh7th/cmp-path" }, + { "hrsh7th/cmp-cmdline" }, + { "hrsh7th/cmp-vsnip" }, + { "hrsh7th/vim-vsnip" }, +} diff --git a/lua/plugins/color-theme.lua b/lua/plugins/color-theme.lua new file mode 100644 index 0000000..6db881a --- /dev/null +++ b/lua/plugins/color-theme.lua @@ -0,0 +1,9 @@ +return { + { + "rose-pine/neovim", + config = function() + vim.cmd("colorscheme rose-pine-moon") + -- vim.cmd.colorscheme("rose-pine") + end + }, +} diff --git a/lua/plugins/comment.lua b/lua/plugins/comment.lua new file mode 100644 index 0000000..36c32a2 --- /dev/null +++ b/lua/plugins/comment.lua @@ -0,0 +1,3 @@ +return { + { "numToStr/Comment.nvim", lazy = false, config = true }, +} diff --git a/lua/plugins/distant.lua b/lua/plugins/distant.lua new file mode 100644 index 0000000..b6f244d --- /dev/null +++ b/lua/plugins/distant.lua @@ -0,0 +1,8 @@ +return { + { + "chipsenkbeil/distant.nvim", + config = function () + require("distant"):setup() + end + }, +} diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..97fafeb --- /dev/null +++ b/lua/plugins/gitsigns.lua @@ -0,0 +1,14 @@ +return { + { + "lewis6991/gitsigns.nvim", + opts = { + signs = { + add = { text = "+" }, + change = { text = "~" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + } + } + }, +} diff --git a/lua/plugins/lsp-signature.lua b/lua/plugins/lsp-signature.lua new file mode 100644 index 0000000..061e2a5 --- /dev/null +++ b/lua/plugins/lsp-signature.lua @@ -0,0 +1,8 @@ +return { + { + "ray-x/lsp_signature.nvim", + event = "VeryLazy", + opts = {}, + config = function (_, opts) require("lsp_signature").setup(opts) end + }, +} diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua new file mode 100644 index 0000000..3ee81a1 --- /dev/null +++ b/lua/plugins/lspconfig.lua @@ -0,0 +1,3 @@ +return { + { "neovim/nvim-lspconfig" }, +} diff --git a/lua/plugins/luasnip.lua b/lua/plugins/luasnip.lua new file mode 100644 index 0000000..6ef8c66 --- /dev/null +++ b/lua/plugins/luasnip.lua @@ -0,0 +1,10 @@ +return { + "L3MON4D3/LuaSnip", + dependencies = { + "rafamadriz/friendly-snippets" + }, + config = function () + require("luasnip.loaders.from_vscode").lazy_load() + end, + build = "make_install_jsregexp" +} diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua new file mode 100644 index 0000000..bab7c21 --- /dev/null +++ b/lua/plugins/mason.lua @@ -0,0 +1,4 @@ +return { + { "williamboman/mason-lspconfig.nvim", config = true }, + { "williamboman/mason.nvim", config = true }, +} diff --git a/lua/plugins/mini.lua b/lua/plugins/mini.lua new file mode 100644 index 0000000..80df5c6 --- /dev/null +++ b/lua/plugins/mini.lua @@ -0,0 +1,11 @@ +return { + "echasnovski/mini.nvim", + config = function() + require("mini.ai").setup({ n_lines = 500 }) + local statusline = require("mini.statusline") + statusline.setup({ use_icons = vim.g.have_nerd_font }) + statusline.section_localtion = function() + return "%21:%-2v" + end + end +} diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua new file mode 100644 index 0000000..f3feb3a --- /dev/null +++ b/lua/plugins/neo-tree.lua @@ -0,0 +1,21 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim" + }, + cmd = "Neotree", + keys = { + { "\\", ":Neotree reveal", { desc = "Neotree reveal" }}, + }, + opts = { + filesystem = { + window = { + mappings = { + ["\\"] = "close_window", + } + } + } + }, +} diff --git a/lua/plugins/neogit.lua b/lua/plugins/neogit.lua new file mode 100644 index 0000000..d6d8347 --- /dev/null +++ b/lua/plugins/neogit.lua @@ -0,0 +1,9 @@ +return { + "NeogitOrg/neogit", + dependencies = { + "nvim-lua/plenary.nvim", + "sindrets/diffview.nvim", + "nvim-telescope/telescope.nvim" + }, + config = true +} diff --git a/lua/plugins/nvim-ufo.lua b/lua/plugins/nvim-ufo.lua new file mode 100644 index 0000000..32c46f6 --- /dev/null +++ b/lua/plugins/nvim-ufo.lua @@ -0,0 +1,21 @@ +return { + "kevinhwang91/nvim-ufo", + dependencies = { + "kevinhwang91/promise-async" + }, + config = function () + vim.o.foldcolumn = "1" + vim.o.foldlevel = 99 + vim.o.foldlevelstart = 99 + vim.o.foldenable = true + + vim.keymap.set("n", "zR", require("ufo").openAllFolds) + vim.keymap.set("n", "zM", require("ufo").closeAllFolds) + + require("ufo").setup({ + provider_selector = function () + return { "treesitter", "indent" } + end + }) + end +} diff --git a/lua/plugins/surround.lua b/lua/plugins/surround.lua new file mode 100644 index 0000000..ae95c55 --- /dev/null +++ b/lua/plugins/surround.lua @@ -0,0 +1,3 @@ +return { + { "kylechui/nvim-surround", event = "VeryLazy", config = true }, +} diff --git a/lua/plugins/tailwind-css-colors.lua b/lua/plugins/tailwind-css-colors.lua new file mode 100644 index 0000000..05dd2d8 --- /dev/null +++ b/lua/plugins/tailwind-css-colors.lua @@ -0,0 +1,3 @@ +return { + { "themaxmarchuk/tailwindcss-colors.nvim" }, +} diff --git a/lua/plugins/telescope-filebrowser.lua b/lua/plugins/telescope-filebrowser.lua new file mode 100644 index 0000000..7b3da43 --- /dev/null +++ b/lua/plugins/telescope-filebrowser.lua @@ -0,0 +1,9 @@ +return { + { + "nvim-telescope/telescope-file-browser.nvim", + dependencies = { + "nvim-telescope/telescope.nvim", + "nvim-lua/plenary.nvim" + }, + }, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..a943b65 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,32 @@ +return { + { + "nvim-telescope/telescope.nvim", + config = function () + require("telescope").setup({ + pickers = { find_files = { hidden = true } }, + extensions = { + file_browser = { + hijack_netrw = true, + grouped = true, + }, + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = "smart_case", + }, + ["ui-select"] = { + require("telescope.themes").get_dropdown(), + }, + }, + }) + pcall(require("telescope").load_extension, "fzf") + pcall(require("telescope").load_extension, "ui-select") + end + }, + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build" + }, + { "nvim-telescope/telescope-ui-select.nvim" }, +} diff --git a/lua/plugins/treesitter-context.lua b/lua/plugins/treesitter-context.lua new file mode 100644 index 0000000..f418b78 --- /dev/null +++ b/lua/plugins/treesitter-context.lua @@ -0,0 +1,5 @@ +return { + { + "nvim-treesitter/nvim-treesitter-context" + }, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..4290a5f --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,12 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + vim.cmd("TSUpdate") + require("nvim-treesitter.configs").setup({ + highlight = { enable = true } + }) + end + } +} diff --git a/lua/plugins/trouble.lua b/lua/plugins/trouble.lua new file mode 100644 index 0000000..872236d --- /dev/null +++ b/lua/plugins/trouble.lua @@ -0,0 +1,8 @@ +return { + { + "folke/trouble.nvim", + config = true, + opts = { + } + }, +} diff --git a/lua/plugins/web-decicons.lua b/lua/plugins/web-decicons.lua new file mode 100644 index 0000000..78b4bb9 --- /dev/null +++ b/lua/plugins/web-decicons.lua @@ -0,0 +1,3 @@ +return { + { "nvim-tree/nvim-web-devicons" }, +} diff --git a/lua/plugins/which-key.lua b/lua/plugins/which-key.lua new file mode 100644 index 0000000..6d1c527 --- /dev/null +++ b/lua/plugins/which-key.lua @@ -0,0 +1,17 @@ +return { + { + "folke/which-key.nvim", + event = "VimEnter", + config = function() + require("which-key").setup() + + require("which-key").register({ + ["c"] = { name = "[C]ode", _ = "which_key_ignore" }, + ["d"] = { name = "[D]ocument", _ = "which_key_ignore" }, + ["r"] = { name = "[R]ename", _ = "which_key_ignore" }, + ["s"] = { name = "[S]earch", _ = "which_key_ignore" }, + ["w"] = { name = "[W]orkspace", _ = "which_key_ignore" }, + }) + end + }, +} diff --git a/options.lua b/options.lua new file mode 100644 index 0000000..dfa8a02 --- /dev/null +++ b/options.lua @@ -0,0 +1,51 @@ +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +vim.opt.showmode = false + +-- vim.opt.guicursor = "" +vim.opt.cursorline = true + +vim.opt.nu = true +vim.opt.relativenumber = true +vim.o.statuscolumn = "%l %=%{v:relnum?v:relnum:v:lnum} " + +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true +vim.opt.tabstop = 4 + +vim.opt.smartindent = true + +vim.opt.wrap = true + +vim.opt.swapfile = false + +vim.opt.incsearch = true +vim.opt.inccommand = "split" + +vim.opt.termguicolors = true + +vim.opt.scrolloff = 10 +vim.opt.signcolumn ="yes" +vim.opt.isfname:append("@-@") + +vim.opt.updatetime = 50 + +vim.opt.colorcolumn = "80" + +vim.opt.clipboard = "unnamedplus" +-- vim.opt.breakindent = true +vim.opt.undofile = true + +vim.opt.ignorecase = true +vim.opt.smartcase = true + +vim.opt.splitright = true +vim.opt.splitbelow = true + +vim.opt.list = true +vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣" } + +vim.opt.hlsearch = false +vim.keymap.set("n", "", "nohlsearch") diff --git a/remap.lua b/remap.lua new file mode 100644 index 0000000..9df10da --- /dev/null +++ b/remap.lua @@ -0,0 +1,63 @@ +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '<-2gv=gv") + +vim.keymap.set("x", "p", "\"_dP") + +-- Telescope +local builtin = require("telescope.builtin") +vim.keymap.set("n", "sh", builtin.help_tags, { desc = "[S]earch [H]elp" }) +vim.keymap.set("n", "sk", builtin.keymaps, { desc = "[S]earch [K]eymaps" }) +vim.keymap.set("n", "sf", builtin.find_files, { desc = "[S]earch [F]iles" }) +vim.keymap.set("n", "ss", builtin.builtin, { desc = "[S]earch [S]elect Telescope" }) +vim.keymap.set("n", "sw", builtin.grep_string, { desc = "[S]earch current [W]ord" }) +vim.keymap.set("n", "sg", builtin.live_grep, { desc = "[S]earch by [G]rep" }) +vim.keymap.set("n", "sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" }) +vim.keymap.set("n", "sr", builtin.resume, { desc = "[S]earch [R]esume" }) +vim.keymap.set("n", "s.", builtin.oldfiles, { desc = "[S]earch Recent Files ('.' for repeat)" }) +vim.keymap.set("n", "bc", ":Telescope file_browser path=%:p:h select_buffer=true", {noremap=true}) +vim.keymap.set("n", "fb", ":Telescope file_browser path=. select_buffer=true", {noremap=true}) +vim.keymap.set("n", "bb", builtin.buffers, { noremap = true }) +vim.keymap.set("n", "/", function() + builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({ + winblend = 10, + previewer = false + })) +end, +{ desc = "[/] Fuzzily search in curent buffer" }) +vim.keymap.set("n", "s/", function() + builtin.live_grep({ + grep_open_files = true, + prompt_title = "Live Grep in Open Files" + }) +end, +{ desc = "[S]earch [/] in Open files" }) +vim.keymap.set("n", "sn", function() + builtin.find_files({ cwd = vim.fn.expand("$XDG_CONFIG_HOME") .. "/nvim/" }) +end, +{ desc = "[S]earch [N]eovim files" }) + +--LSP +vim.keymap.set("n", "e", vim.diagnostic.open_float) +vim.keymap.set("n", "[d", vim.diagnostic.goto_prev) +vim.keymap.set("n", "]d", vim.diagnostic.goto_next) +vim.keymap.set("n", "q", vim.diagnostic.setloclist) + +--Highlight on yank +vim.api.nvim_create_autocmd("TextYankPost", { + desc = "Highlight when yanking (copying) text", + group = vim.api.nvim_create_augroup("highlight-yank", { clear = true }), + callback = function() + vim.highlight.on_yank() + end +}) + +--ToggleTerm +-- vim.keymap.set("n", "", ":execute v:count1 . \"ToggleTerm\"") +-- vim.keymap.set("t", "", "") + +--Trouble +-- local trouble = require("trouble") +-- vim.keymap.set("n", "xx", function() trouble.toggle("workspace_diagnostics") end, { desc = "Toggle Trouble" }) +-- vim.keymap.set("n", "xq", function() trouble.toggle("quickfix") end, { desc = "Toggle [Q]uickfix list" }) +-- vim.keymap.set("n", "xl", function() trouble.toggle("loclist") end, { desc = "Toggle [L]oc list" }) +--