From 2c3b306495070c8b20a1f28f9f7143917bbff9e6 Mon Sep 17 00:00:00 2001 From: Guanran Wang Date: Sat, 14 Sep 2024 20:17:10 +0800 Subject: [PATCH] treewide: chores --- lua/options.lua | 19 ++++++++----------- lua/plugins/completion.lua | 38 +++++++++++++++++++++++++++----------- lua/plugins/null-ls.lua | 2 +- lua/plugins/nvim-tree.lua | 5 ++++- lua/plugins/telescope.lua | 2 +- 5 files changed, 41 insertions(+), 25 deletions(-) diff --git a/lua/options.lua b/lua/options.lua index c20fe5a..882c984 100755 --- a/lua/options.lua +++ b/lua/options.lua @@ -13,8 +13,11 @@ vim.opt.cursorline = true vim.opt.number = true vim.opt.relativenumber = true +-- Breakindent +vim.opt.breakindent = true + -- Mouse -vim.cmd([[ +vim.cmd([[ aunmenu PopUp.How-to\ disable\ mouse aunmenu PopUp.-1- ]]) @@ -29,7 +32,10 @@ vim.opt.ignorecase = true vim.opt.smartcase = true -- System integration -vim.opt.clipboard = "unnamedplus" +-- https://github.com/nvim-lua/kickstart.nvim/blob/7201dc480134f41dd1be1f8f9b8f8470aac82a3b/init.lua#L113-L119 +vim.schedule(function() + vim.opt.clipboard = "unnamedplus" +end) vim.opt.swapfile = false vim.opt.undofile = true @@ -42,12 +48,3 @@ vim.opt.tabstop = 2 vim.opt.laststatus = 3 vim.opt.showmode = false -- Handled by lualine vim.opt.signcolumn = "yes" -- Prevents shifting - --- Neovide specific settings -if vim.g.neovide then - vim.opt.guifont = "monospace:h12" - - -- Terminal-emulator-like copy/pasting - vim.api.nvim_set_keymap("n", "", '"+y', { noremap = true, silent = true }) - vim.api.nvim_set_keymap("n", "", '"+p', { noremap = true, silent = true }) -end diff --git a/lua/plugins/completion.lua b/lua/plugins/completion.lua index 7ea9f5d..af51344 100644 --- a/lua/plugins/completion.lua +++ b/lua/plugins/completion.lua @@ -6,12 +6,19 @@ return { "hrsh7th/cmp-cmdline", "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-path", + "saadparwaiz1/cmp_luasnip", "neovim/nvim-lspconfig", -- Snippets - "L3MON4D3/LuaSnip", -- snippet engine - "rafamadriz/friendly-snippets", -- pre-configured snippet texts - "saadparwaiz1/cmp_luasnip", -- nvim-cmp source + { + "L3MON4D3/LuaSnip", -- snippet engine + dependencies = { + "rafamadriz/friendly-snippets", -- pre-configured snippet texts + config = function() + require("luasnip.loaders.from_vscode").lazy_load() + end, + }, + }, }, event = { "InsertEnter", "CmdlineEnter" }, opts = function() @@ -23,8 +30,6 @@ return { return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil end - require("luasnip.loaders.from_vscode").lazy_load() - cmp.setup({ -- keybinds -- see: https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings @@ -32,10 +37,8 @@ return { [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif has_words_before() then - cmp.complete() + elseif luasnip.locally_jumpable(1) then + luasnip.jump(1) else fallback() end @@ -44,14 +47,27 @@ return { [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() - elseif luasnip.jumpable(-1) then + elseif luasnip.locally_jumpable(-1) then luasnip.jump(-1) else fallback() end end, { "i", "s" }), - [""] = cmp.mapping.confirm(), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + if luasnip.expandable() then + luasnip.expand() + else + cmp.confirm({ + select = true, + }) + end + else + fallback() + end + end), + [""] = cmp.mapping.select_prev_item({ behavior = "select" }), [""] = cmp.mapping.select_next_item({ behavior = "select" }), }, diff --git a/lua/plugins/null-ls.lua b/lua/plugins/null-ls.lua index 7709b59..a2067fa 100644 --- a/lua/plugins/null-ls.lua +++ b/lua/plugins/null-ls.lua @@ -15,7 +15,7 @@ return { end, keys = { { - "lf", + "f", function() vim.lsp.buf.format() end, diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index e8d3366..fef4df6 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -2,7 +2,10 @@ return { "nvim-tree/nvim-tree.lua", opts = { view = { - adaptive_size = true, + side = "right", + }, + renderer = { + symlink_destination = false, -- usually too long }, }, init = function() diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index cde1036..ff75067 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -7,8 +7,8 @@ return { opts = {}, cmd = "Telescope", keys = { - { "f", "Telescope find_files", desc = "Find files" }, { "", "Telescope oldfiles", desc = "Recent files" }, + { "sf", "Telescope find_files", desc = "Find files" }, { "sg", "Telescope live_grep", desc = "Live grep" }, }, }