From 3e2dd9c3322a2104a31900cc412ffbf64fc9eae4 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Thu, 4 Jan 2024 00:45:21 +0100 Subject: [PATCH] most usable config --- init.lua | 2 +- lua/keymappings.lua | 11 +++---- lua/lsp.lua | 11 ++++--- lua/plugins/cmp.lua | 60 +++++++++++++++++++++++++++++++------- lua/plugins/init.lua | 12 +++++++- lua/plugins/treesitter.lua | 11 +++---- 6 files changed, 77 insertions(+), 30 deletions(-) diff --git a/init.lua b/init.lua index 838f16d..dc312bd 100644 --- a/init.lua +++ b/init.lua @@ -4,7 +4,7 @@ vim.g.mapleader = ' ' -- Sensible defaults require('settings') require('plugins') -require('keymappings') require('lsp') require('filetypes') require('theme') +require('keymappings') diff --git a/lua/keymappings.lua b/lua/keymappings.lua index d56d803..2f6751b 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -1,15 +1,16 @@ local utils = require('utils') --- Clear highlights (search + trailing whitespace) -utils.map('n', '', 'noh') -utils.map("n", "", "let _s=@/:%s/\\s\\+$//e:let @/=_s") + +-- Clear trailing whitespace +utils.map("n", "", "let _s=@/:%s/\\s\\+$//e:let @/=_s") -- Use tab and shift+tab to cycle buffers utils.map("n", "", "bn") utils.map("n", "", "bp") --- Turn spellchecker on +-- Turn spellchecker on and off utils.map("n", "se", "setlocal spell spelllang=en_us") +utils.map("n", "sq", "setlocal nospell") --- Toggle line numbers and file tree utils.map("n", "", "set nonumber!") utils.map("n", "fe", "Oil") +utils.map("n", "", "Neotree toggle") diff --git a/lua/lsp.lua b/lua/lsp.lua index aed2cbe..eef7984 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -8,10 +8,9 @@ local on_attach = function(client, bufnr) utils.map("n", "", "lua vim.lsp.buf.signature_help()") utils.map("n", "", "lua vim.lsp.buf.type_definition()") utils.map("n", "", "lua vim.lsp.buf.rename()()") - + utils.map("n", "[d", "lua vim.diagnostic.goto_prev()") + utils.map("n", "]d", "lua vim.diagnostic.goto_next()") utils.map("n", "ca", "lua vim.lsp.buf.code_action()") - - -- list/add/remove workspace folders, not that I use them often utils.map("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))") utils.map("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") utils.map("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") @@ -76,9 +75,9 @@ nvim_lsp.rust_analyzer.setup({ enable = true, }, }, - procMacro = { - enable = true - }, + --procMacro = { + -- enable = true + --}, checkOnSave = { command = "clippy", }, diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 8953f76..05ab1a0 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -2,12 +2,53 @@ local utils = require('utils') ---vim.cmd [[set shortmess+=c]] ---utils.opt('o', 'completeopt', 'menuone,noselect') +vim.cmd [[set shortmess+=c]] +utils.opt('o', 'completeopt', 'menuone,noselect') local cmp = require('cmp') +local cmp_kinds = { + 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({ + formatting = { + format = function(entry, vim_item) + -- Kind icons + vim_item.kind = string.format('%s %s', cmp_kinds[vim_item.kind], vim_item.kind) + vim_item.menu = ({ + buffer = "[Buffer]", + nvim_lsp = "[LSP]", + luasnip = "[LuaSnip]", + nvim_lua = "[Lua]", + latex_symbols = "[LaTeX]", + })[entry.source.name] + return vim_item + end + }, snippet = { -- REQUIRED - you must specify a snippet engine expand = function(args) @@ -27,7 +68,6 @@ cmp.setup({ mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), [''] = cmp.mapping.complete(), [''] = cmp.mapping.abort(), [''] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. @@ -44,13 +84,13 @@ cmp.setup({ }) -- Set configuration for specific filetype. -cmp.setup.filetype('gitcommit', { - sources = cmp.config.sources({ - { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). - }, { - { name = 'buffer' }, - }) -}) +--cmp.setup.filetype('gitcommit', { +-- sources = cmp.config.sources({ +-- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). +-- }, { +-- { name = 'buffer' }, +-- }) +--}) -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). cmp.setup.cmdline({ '/', '?' }, { diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 9618355..811f745 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -5,6 +5,16 @@ require('packer').startup(function() -- Packer can manage itself as an optional plugin use {'wbthomason/packer.nvim', opt = true } + use { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + requires = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + } + } + -- Fuzzy finder use { 'nvim-telescope/telescope.nvim', @@ -53,7 +63,7 @@ require('packer').startup(function() } use { "lewis6991/gitsigns.nvim" } - -- Filesystem in a nvim buffer + -- Filesystem browser use { 'stevearc/oil.nvim' } -- Misc diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index f564586..4eb2d0f 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -8,16 +8,13 @@ require('nvim-treesitter.configs').setup { ident = { enable = true, }, - incremental_selection = { + rainbow = { enable = true, - keymaps = { - init_selection = "gnn", -- set to `false` to disable one of the mappings - node_incremental = "grn", - scope_incremental = "grc", - node_decremental = "grm", - }, + extended_mode = false, + max_file_lines = nil, } } vim.api.nvim_set_hl(0, "@variable", { }) vim.api.nvim_set_hl(0, "@parameter", { }) +vim.api.nvim_set_hl(0, "@field", { })