diff options
Diffstat (limited to 'lua')
-rw-r--r-- | lua/plugins/init.lua | 78 | ||||
-rw-r--r-- | lua/plugins/maps.lua | 1 | ||||
-rw-r--r-- | lua/plugins/opts/cmp.lua | 96 | ||||
-rw-r--r-- | lua/plugins/opts/lspconfig.lua | 35 | ||||
-rw-r--r-- | lua/plugins/opts/lualine.lua | 4 | ||||
-rw-r--r-- | lua/plugins/opts/misc.lua | 11 | ||||
-rw-r--r-- | lua/plugins/opts/treesitter.lua | 2 |
7 files changed, 217 insertions, 10 deletions
diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 59da877..07d7639 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -10,24 +10,25 @@ require("lazy").setup({ { "nvim-lualine/lualine.nvim", - dependencies = { 'nvim-tree/nvim-web-devicons' }, opts = require "plugins.opts.lualine", }, { - "tiagovla/tokyodark.nvim", + "folke/tokyonight.nvim", lazy = false, + priority = 1000, - opts = { transparent_background = true }, + opts = { transparent = true, }, config = function(_, opts) - require("tokyodark").setup(opts) - vim.cmd.colorscheme "tokyodark" + require("tokyonight").setup(opts) + vim.cmd.colorscheme "tokyonight-night" end, }, { - "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", event = { "BufReadPost", "BufNewFile" }, cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" }, @@ -37,4 +38,69 @@ require("lazy").setup({ end, }, + { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v3.x', + lazy = true, + + config = false, + init = function() + -- Disable automatic setup, we are doing it manually + vim.g.lsp_zero_extend_cmp = 0 + vim.g.lsp_zero_extend_lspconfig = 0 + end, + }, + + { + 'hrsh7th/nvim-cmp', + event = 'InsertEnter', + dependencies = { + { + 'L3MON4D3/LuaSnip', + dependencies = "rafamadriz/friendly-snippets", + + config = function(_, opts) + require("plugins.opts.misc").luasnip(opts) + end, + }, + { + "windwp/nvim-autopairs", + + opts = { + fast_wrap = {}, + disable_filetype = { "TelescopePrompt", "vim" }, + }, + config = function(_, opts) + require("nvim-autopairs").setup(opts) + + -- setup cmp for autopairs + local cmp_autopairs = require "nvim-autopairs.completion.cmp" + require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done()) + end, + }, + -- cmp sources plugins + { + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + }, + }, + + opts = function() + return require "plugins.opts.cmp" + end, + + }, + + { + 'neovim/nvim-lspconfig', + cmd = 'LspInfo', + event = { 'BufReadPre', 'BufNewFile' }, + + config = function() + require "plugins.opts.lspconfig" + end, + }, }) diff --git a/lua/plugins/maps.lua b/lua/plugins/maps.lua index ab10383..7c5f29b 100644 --- a/lua/plugins/maps.lua +++ b/lua/plugins/maps.lua @@ -4,7 +4,6 @@ local maps = {} maps.gitsigns = { n = { ["<leader>gb"] = { - -- TODO: remov fun function() package.loaded.gitsigns.blame_line() end, diff --git a/lua/plugins/opts/cmp.lua b/lua/plugins/opts/cmp.lua new file mode 100644 index 0000000..c423a31 --- /dev/null +++ b/lua/plugins/opts/cmp.lua @@ -0,0 +1,96 @@ +local cmp = require "cmp" +local lspzero_cmp_act = require('lsp-zero').cmp_action() + +local function border(hl_name) + return { + { "╭", hl_name }, + { "─", hl_name }, + { "╮", hl_name }, + { "│", hl_name }, + { "╯", hl_name }, + { "─", hl_name }, + { "╰", hl_name }, + { "│", hl_name }, + } +end + +local options = { + completion = { + completeopt = "menu,menuone", + }, + + window = { + completion = { + border = border "CmpBorder", + winhighlight = "Normal:CmpPmenu,CursorLine:CmpSel,CursorLine:PmenuSel", + scrollbar = false, + }, + documentation = { + border = border "CmpDocBorder", + winhighlight = "Normal:CmpDoc", + }, + }, + + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + + formatting = { + fields = { "abbr", "kind", "menu" }, + + format = function(_, item) + local icons = { + 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 = " ", + } + + local icon = icons[item.kind] or "" + item.kind = string.format(" %s %s", icon, item.kind) + + return item + end, + }, + + mapping = cmp.mapping.preset.insert({ + ['<C-Space>'] = cmp.mapping.complete(), + ['<C-u>'] = cmp.mapping.scroll_docs(-4), + ['<C-d>'] = cmp.mapping.scroll_docs(4), + ['<C-f>'] = lspzero_cmp_act.luasnip_jump_forward(), + ['<C-b>'] = lspzero_cmp_act.luasnip_jump_backward(), + }), + + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "nvim_lua" }, + { name = "path" }, + }, +} + +return options diff --git a/lua/plugins/opts/lspconfig.lua b/lua/plugins/opts/lspconfig.lua new file mode 100644 index 0000000..798e6c8 --- /dev/null +++ b/lua/plugins/opts/lspconfig.lua @@ -0,0 +1,35 @@ +local lspconfig = require "lspconfig" +local lsp_zero = require "lsp-zero" + +lsp_zero.extend_lspconfig() +lsp_zero.set_sign_icons({ + error = " ", + warn = " ", + info = " ", + hint = " " +}) +lsp_zero.on_attach(function(_, bufnr) + lsp_zero.default_keymaps({buffer = bufnr}) +end) + +lspconfig.lua_ls.setup(lsp_zero.nvim_lua_ls({ + settings = { + Lua = { + diagnostics = { + globals = { 'mp' } -- mpv global + } + } + } +})) + +lspconfig.ccls.setup { + init_options = { + cache = { + directory = vim.fn.stdpath('cache') .. '/ccls' + } + } +} + +lspconfig.bashls.setup {} +lspconfig.nil_ls.setup {} +lspconfig.pyright.setup {} diff --git a/lua/plugins/opts/lualine.lua b/lua/plugins/opts/lualine.lua index e72c632..456fa37 100644 --- a/lua/plugins/opts/lualine.lua +++ b/lua/plugins/opts/lualine.lua @@ -4,8 +4,8 @@ return { lualine_b = { "branch", "diff" }, lualine_c = {{ "buffers", mode = 2 }}, - lualine_x = {}, - lualine_y = { "diagnostics", "progress" }, + lualine_x = { "diagnostics" }, + lualine_y = { "progress" }, lualine_z = {}, }, diff --git a/lua/plugins/opts/misc.lua b/lua/plugins/opts/misc.lua index 952dc4f..e228023 100644 --- a/lua/plugins/opts/misc.lua +++ b/lua/plugins/opts/misc.lua @@ -16,4 +16,15 @@ M.gitsigns = { end, } +M.luasnip = function (opts) + require("luasnip").config.set_config(opts) + + -- vscode format + require("luasnip.loaders.from_vscode").lazy_load() + -- snipmate format + require("luasnip.loaders.from_snipmate").lazy_load() + -- lua format + require("luasnip.loaders.from_lua").lazy_load() +end + return M diff --git a/lua/plugins/opts/treesitter.lua b/lua/plugins/opts/treesitter.lua index c9f9a59..fbc2a71 100644 --- a/lua/plugins/opts/treesitter.lua +++ b/lua/plugins/opts/treesitter.lua @@ -1,5 +1,5 @@ return { - ensure_installed = { "lua", "c", "bash"}, + ensure_installed = { "lua", "c", "bash", "nix", "python", "markdown" }, sync_install = false, indent = { enable = true }, |