diff options
| author | Ariel D'Alessandro <ariel.dalessandro@auto1.com> | 2022-02-09 17:53:48 +0100 |
|---|---|---|
| committer | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2022-02-10 07:31:32 +0100 |
| commit | 77f5dd9693576af7fde80bdc99700f21eff01d6b (patch) | |
| tree | ebb4a64a4137c27b5771af8a95944b9dee92c8f5 /after/plugin | |
| parent | cd15d17a96390879c90e95ad90e0f75629e3eed7 (diff) | |
| download | nvim-conf-77f5dd9693576af7fde80bdc99700f21eff01d6b.tar.gz nvim-conf-77f5dd9693576af7fde80bdc99700f21eff01d6b.zip | |
WIP moving to all lua and new structure
Diffstat (limited to 'after/plugin')
| -rw-r--r-- | after/plugin/colors.lua | 16 | ||||
| -rw-r--r-- | after/plugin/completition.lua | 96 | ||||
| -rw-r--r-- | after/plugin/harpoon.lua | 14 | ||||
| -rw-r--r-- | after/plugin/lsp.lua | 43 | ||||
| -rw-r--r-- | after/plugin/lualine.lua | 36 | ||||
| -rw-r--r-- | after/plugin/luasnip.lua | 7 | ||||
| -rw-r--r-- | after/plugin/treesitter.lua | 64 |
7 files changed, 276 insertions, 0 deletions
diff --git a/after/plugin/colors.lua b/after/plugin/colors.lua new file mode 100644 index 0000000..d6d0d18 --- /dev/null +++ b/after/plugin/colors.lua @@ -0,0 +1,16 @@ +local Color, colors, Group, groups, styles = require('colorbuddy').setup() + +-- Use Color.new(<name>, <#rrggbb>) to create new colors +-- They can be accessed through colors.<name> +Color.new('background', '#282c34') +Color.new('red', '#cc6666') +Color.new('green', '#99cc99') +Color.new('yellow', '#f0c674') + +-- Define highlights in terms of `colors` and `groups` +Group.new('Comment' , colors.yellow , colors.background , styles.bold) +Group.new('Special' , groups.Comment , groups.Comment , groups.Comment) +Group.new('NonText' , groups.Comment , groups.Comment , groups.Comment) + +-- Define highlights in relative terms of other colors +Group.new('Error' , colors.red:light() , nil , styles.bold) diff --git a/after/plugin/completition.lua b/after/plugin/completition.lua new file mode 100644 index 0000000..7140ca5 --- /dev/null +++ b/after/plugin/completition.lua @@ -0,0 +1,96 @@ +local lspkind = require "lspkind" + +local luasnip = require("luasnip") +local cmp = require "cmp" +local cmp_autopairs = require('nvim-autopairs.completion.cmp') +cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) + +cmp.setup { + mapping = { + ["<C-d>"] = cmp.mapping.scroll_docs(-4), + ["<C-f>"] = cmp.mapping.scroll_docs(4), + ["<C-e>"] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.close() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + ["<C-n>"] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.choice_active() then + luasnip.change_choice(1) + else + fallback() + end + end, { "i", "s" }), + ["<C-y>"] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }, + ["<c-space>"] = cmp.mapping.complete(), + }, + sources = { + { name = "nvim_lua" }, + { name = "nvim_lsp" }, + { name = "path" }, + { name = "luasnip" }, + { + name = "buffer", + keyword_length = 5, + option = { + get_bufnrs = function() + local bufs = {} + for _, win in ipairs(vim.api.nvim_list_wins()) do + bufs[vim.api.nvim_win_get_buf(win)] = true + end + return vim.tbl_keys(bufs) + end + } + }, + }, + + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + + formatting = { + format = lspkind.cmp_format { + with_text = true, + menu = { + buffer = "[buf]", + nvim_lsp = "[LSP]", + nvim_lua = "[api]", + path = "[path]", + luasnip = "[snip]", + } + } + }, + + experimental = { + native_menu = false, + + ghost_text = true, + } +} +-- Setup lspconfig. + local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) + -- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled. + require('lspconfig')['emmet_ls'].setup { + capabilities = capabilities + } + +local Group = require("colorbuddy.group").Group +local g = require("colorbuddy.group").groups +local s = require("colorbuddy.style").styles + +Group.new("CmpItemAbbr", g.Comment) +Group.new("CmpItemAbbrDeprecated", g.Error) +Group.new("CmpItemAbbrMatchFuzzy", g.CmpItemAbbr.fg:dark(), nil, s.italic) +Group.new("CmpItemKind", g.Special) +Group.new("CmpItemMenu", g.NonText) diff --git a/after/plugin/harpoon.lua b/after/plugin/harpoon.lua new file mode 100644 index 0000000..087b29f --- /dev/null +++ b/after/plugin/harpoon.lua @@ -0,0 +1,14 @@ +local ok, harpoon = pcall(require, "harpoon") +if not ok then + return +end + +harpoon.setup {} + +vim.api.nvim_set_keymap("n", "<Leader>ss", [[ <Cmd>lua require("harpoon.ui").toggle_quick_menu()<CR>]], {noremap = true, silent = true, expr = false}) + +vim.api.nvim_set_keymap("n", "<Leader>sa", [[ <Cmd>lua require("harpoon.mark").add_file()<CR>]], {noremap = true, silent = true, expr = false}) +vim.api.nvim_set_keymap("n", "<Leader>su", [[ <Cmd>lua require("harpoon.ui").nav_file(1)<CR>]], {noremap = true, silent = true, expr = false}) +vim.api.nvim_set_keymap("n", "<Leader>si", [[ <Cmd>lua require("harpoon.ui").nav_file(2)<CR>]], {noremap = true, silent = true, expr = false}) +vim.api.nvim_set_keymap("n", "<Leader>so", [[ <Cmd>lua require("harpoon.ui").nav_file(3)<CR>]], {noremap = true, silent = true, expr = false}) +vim.api.nvim_set_keymap("n", "<Leader>sp", [[ <Cmd>lua require("harpoon.ui").nav_file(4)<CR>]], {noremap = true, silent = true, expr = false}) diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua new file mode 100644 index 0000000..40a56d6 --- /dev/null +++ b/after/plugin/lsp.lua @@ -0,0 +1,43 @@ +local function on_attach() + -- keymaps for lsp + vim.api.nvim_set_keymap('n', 'K', ':lua vim.lsp.buf.hover()<cr>', {noremap = true}) + vim.api.nvim_set_keymap('n', '<leader>vd', ':lua vim.lsp.buf.definition()<cr>', {noremap = true}) + + + vim.api.nvim_set_keymap('n', '<leader>vo', ':LspRestart<cr>', {noremap = true}) + + -- diagnostics to move between info and errors + vim.api.nvim_set_keymap('n', '<leader>vn', ':lua vim.lsp.diagnostic.goto_next()<cr>', {noremap = true}) + vim.api.nvim_set_keymap('n', '<leader>vp', ':lua vim.lsp.diagnostic.goto_prev()<cr>', {noremap = true}) + + + vim.api.nvim_set_keymap('n', '<leader>vca', ':lua vim.lsp.buf.code_action()<cr>', {noremap = true}) + vim.api.nvim_set_keymap('n', '<leader>vf', ':lua vim.lsp.buf.formatting()<cr>', {noremap = true}) + + vim.api.nvim_set_keymap('n', '<leader>vi', ':lua vim.lsp.buf.implementation()<cr>', {noremap = true}) + vim.api.nvim_set_keymap('n', '<leader>vrn', ':lua vim.lsp.buf.rename()<cr>', {noremap = true}) + + require "lsp_signature".on_attach() + + vim.cmd [[au Filetype php setl omnifunc=v:lua.vim.lsp.omnifunc]] + vim.cmd [[autocmd FileType go setlocal omnifunc=v:lua.vim.lsp.omnifunc]] + + vim.g.completion_matching_strategy_list = { 'exact', 'substring', 'fuzzy' } + +end + +local lsp_installer = require("nvim-lsp-installer") + +lsp_installer.on_server_ready(function(server) + local opts = {} + + -- (optional) Customize the options passed to the server + if server.name == "emmet_ls" then + opts.filetypes = {"html", "css", "blade"} + end + + opts.on_attach = on_attach + -- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart) + server:setup(opts) + vim.cmd [[ do User LspAttachBuffers ]] +end) diff --git a/after/plugin/lualine.lua b/after/plugin/lualine.lua new file mode 100644 index 0000000..bfd449a --- /dev/null +++ b/after/plugin/lualine.lua @@ -0,0 +1,36 @@ +local ok, lualine = pcall(require, "lualine") +if not ok then + return +end + +lualine.setup{ + options = { + theme = 'dracula', + icons_enabled = true, + }, + extensions = {'quickfix', 'fugitive'}, + sections = { + lualine_a = { { 'mode', upper = true } }, + lualine_b = { { 'branch', icon = '' }, 'diff' }, + lualine_c = { { 'filename', file_status = true, path = 1 } }, + lualine_x = { { 'diagnostics', sources = { 'nvim_diagnostic' } },'encoding', 'fileformat', 'filetype' }, + lualine_y = { 'progress' }, + lualine_z = { 'location' }, + }, + inactive_sections = { + lualine_a = { }, + lualine_b = { }, + lualine_c = { 'filename' }, + lualine_x = { 'location' }, + lualine_y = { }, + lualine_z = { }, + }, + -- tabline = { + -- lualine_a = {'buffers'}, + -- lualine_b = {}, + -- lualine_c = {}, + -- lualine_x = {}, + -- lualine_y = {}, + -- lualine_z = {'tabs'} + -- } + } diff --git a/after/plugin/luasnip.lua b/after/plugin/luasnip.lua new file mode 100644 index 0000000..9a1c3db --- /dev/null +++ b/after/plugin/luasnip.lua @@ -0,0 +1,7 @@ +if vim.g.snippets ~= "luasnip" then + return +end + + +-- shorcut to source my luasnips file again, which will reload my snippets +vim.keymap.set("n", "<leader><leader>s", "<cmd>source ~/.config/nvim/after/plugin/luasnip.lua<CR>") diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua new file mode 100644 index 0000000..f2f5360 --- /dev/null +++ b/after/plugin/treesitter.lua @@ -0,0 +1,64 @@ +if not pcall(require, "nvim-treesitter") then + return +end + +require "nvim-treesitter.configs".setup { + ensure_installed = {"php", "go", "comment", "css", "html", "javascript", "lua", "typescript"}, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + indent = { + enable = true, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, + }, + refactor = { + highlight_definitions = { enable = true }, + smart_rename = { + enable = true, + keymaps = { + smart_rename = "grr", + }, + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@conditional.outer", + ["ic"] = "@conditional.inner", + ["al"] = "@loop.outer", + ["il"] = "@loop.inner", + } + } + }, + playground = { + enable = true, + disable = {}, + updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code + persist_queries = false, -- Whether the query persists across vim sessions + keybindings = { + toggle_query_editor = 'o', + toggle_hl_groups = 'i', + toggle_injected_languages = 't', + toggle_anonymous_nodes = 'a', + toggle_language_display = 'I', + focus_language = 'f', + unfocus_language = 'F', + update = 'R', + goto_node = '<cr>', + show_help = '?', + }, + } +} |