aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAriel D'Alessandro <dalessandro.ariel@gmail.com>2021-11-25 00:05:34 +0100
committerAriel D'Alessandro <dalessandro.ariel@gmail.com>2021-11-25 00:05:59 +0100
commit412f51cd7ad4ce610ecaf13210b52709fb3e0232 (patch)
treebf6475830cc0df42b671bf7ce9a1b33fe70f0e37
parent31efe743072b868d4bb86ed709b85253db0b1f60 (diff)
downloadnvim-conf-412f51cd7ad4ce610ecaf13210b52709fb3e0232.tar.gz
nvim-conf-412f51cd7ad4ce610ecaf13210b52709fb3e0232.zip
Move config to lua. Add laravel snippets
-rw-r--r--init.vim1
-rw-r--r--lua/alpha/completition.lua32
-rw-r--r--lua/alpha/global.lua13
-rw-r--r--lua/alpha/init.lua4
-rw-r--r--lua/alpha/lsp.lua47
-rw-r--r--lua/alpha/snippets.lua29
-rw-r--r--lua/alpha/snippets/config.lua34
-rw-r--r--lua/alpha/snippets/init.lua1
-rw-r--r--lua/alpha/snippets/php.lua122
-rw-r--r--lua/alpha/treesitter.lua (renamed from plugin/treesitter.vim)4
-rw-r--r--lua/plugins.lua4
-rw-r--r--plugin/alpha.vim13
-rw-r--r--plugin/keymap.vim1
-rw-r--r--plugin/lsp.vim43
-rw-r--r--plugin/plugins.vim1
-rw-r--r--plugin/sets.vim2
-rw-r--r--plugin/status.vim1
17 files changed, 267 insertions, 85 deletions
diff --git a/init.vim b/init.vim
index e90d0b1..b0acc39 100644
--- a/init.vim
+++ b/init.vim
@@ -52,6 +52,7 @@ inoremap > ><c-g>u
vnoremap < <gv
vnoremap > >gv
+lua require('plugins')
lua require("alpha")
" Has to be the last line for the .nvimrc per project
diff --git a/lua/alpha/completition.lua b/lua/alpha/completition.lua
index d91dccc..98a2c86 100644
--- a/lua/alpha/completition.lua
+++ b/lua/alpha/completition.lua
@@ -3,6 +3,8 @@ lspkind.init()
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 = {
@@ -17,6 +19,15 @@ cmp.setup {
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,
@@ -25,11 +36,10 @@ cmp.setup {
},
sources = {
{ name = "nvim_lua" },
-
{ name = "nvim_lsp" },
{ name = "path" },
{ name = "luasnip" },
- { name = "buffer", keyword_length = 5 },
+ { name = "buffer", keyword_length = 3 },
},
snippet = {
@@ -41,11 +51,13 @@ cmp.setup {
formatting = {
format = lspkind.cmp_format {
with_text = true,
- buffer = "[buf]",
- nvim_lsp = "[LSP]",
- nvim_lua = "[api]",
- path = "[path]",
- luasnip = "[snip]",
+ menu = {
+ buffer = "[buf]",
+ nvim_lsp = "[LSP]",
+ nvim_lua = "[api]",
+ path = "[path]",
+ luasnip = "[snip]",
+ }
}
},
@@ -55,6 +67,12 @@ cmp.setup {
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
diff --git a/lua/alpha/global.lua b/lua/alpha/global.lua
new file mode 100644
index 0000000..5fcee70
--- /dev/null
+++ b/lua/alpha/global.lua
@@ -0,0 +1,13 @@
+P = function (v)
+ print(vim.inspect(v))
+ return v
+end
+
+RELOAD = function (...)
+ return require("plenary.reload").reload_module(...)
+end
+
+R = function (name)
+ RELOAD(name)
+ return require(name)
+end
diff --git a/lua/alpha/init.lua b/lua/alpha/init.lua
index 2ab9a0f..7b58612 100644
--- a/lua/alpha/init.lua
+++ b/lua/alpha/init.lua
@@ -1,6 +1,10 @@
+require("alpha.global")
require("alpha.telescope")
require("alpha.refactoring")
require("alpha.snippets")
require("alpha.harpoon")
require("alpha.refactor")
require("alpha.completition")
+require("alpha.lsp")
+require("alpha.treesitter")
+require("alpha.status-line")
diff --git a/lua/alpha/lsp.lua b/lua/alpha/lsp.lua
new file mode 100644
index 0000000..c164846
--- /dev/null
+++ b/lua/alpha/lsp.lua
@@ -0,0 +1,47 @@
+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>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})
+
+ -- not sure since when I need signature help cant access this, maybe move to normal, but already have
+ -- the new snippet for the floating
+ -- vim.api.nvim_set_keymap('n', '<leader>vsh', ':lua vim.lsp.buf.signature_help()<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/lua/alpha/snippets.lua b/lua/alpha/snippets.lua
deleted file mode 100644
index bdf217b..0000000
--- a/lua/alpha/snippets.lua
+++ /dev/null
@@ -1,29 +0,0 @@
-local ls = require"luasnip"
-local s = ls.snippet
-local sn = ls.snippet_node
-local t = ls.text_node
-local i = ls.insert_node
-local f = ls.function_node
-local c = ls.choice_node
-local d = ls.dynamic_node
-
-ls.snippets = {
- php = {
- s("$", {
- t("$this->"),
- }),
- s("v", {
- t({ "/**", " * @var " }),
- i(1, "types"),
- t({""," */", "private $"}),
- i(2, "name"),
- t(";", ""),
- }),
- s("pf", {
- t("public function"), i(1, "name"), t("("), i(2, "$arg"), t(")"),
- t({"", "{"}),
- i(0, " "),
- t({"", "}"})
- }),
- }
-}
diff --git a/lua/alpha/snippets/config.lua b/lua/alpha/snippets/config.lua
new file mode 100644
index 0000000..ff438c2
--- /dev/null
+++ b/lua/alpha/snippets/config.lua
@@ -0,0 +1,34 @@
+local ls = require"luasnip"
+local s = ls.snippet
+local sn = ls.snippet_node
+local t = ls.text_node
+local i = ls.insert_node
+local f = ls.function_node
+local c = ls.choice_node
+local d = ls.dynamic_node
+-- local types = require("luasnip.util.types")
+
+-- Every unspecified option will be set to the default.
+ls.config.set_config({
+ history = true,
+ -- Update more often, :h events for more info.
+ updateevents = "TextChanged,TextChangedI",
+ -- ext_opts = {
+ -- [types.choiceNode] = {
+ -- active = {
+ -- virt_text = { { "choiceNode", "Comment" } },
+ -- },
+ -- },
+ -- },
+ -- treesitter-hl has 100, use something higher (default is 200).
+ ext_base_prio = 300,
+ -- minimal increase in priority.
+ ext_prio_increase = 1,
+ enable_autosnippets = true,
+})
+
+-- ls.snippets = {
+-- php = require('alpha.snippets.php')
+-- }
+
+vim.api.nvim_set_keymap("i", "<c-k>", "<Plug>luasnip-expand-or-jump", {})
diff --git a/lua/alpha/snippets/init.lua b/lua/alpha/snippets/init.lua
new file mode 100644
index 0000000..8318486
--- /dev/null
+++ b/lua/alpha/snippets/init.lua
@@ -0,0 +1 @@
+require('alpha.snippets.config')
diff --git a/lua/alpha/snippets/php.lua b/lua/alpha/snippets/php.lua
new file mode 100644
index 0000000..c8c2053
--- /dev/null
+++ b/lua/alpha/snippets/php.lua
@@ -0,0 +1,122 @@
+local ls = require"luasnip"
+local s = ls.snippet
+local sn = ls.snippet_node
+local t = ls.text_node
+local i = ls.insert_node
+local c = ls.choice_node
+local d = ls.dynamic_node
+
+-- visibility allows to reuse it pasing the first option to show for the
+-- snippet
+local visibility
+visibility = function (_, _, _, initial_text)
+ local possibles = {'private', 'public', 'protected'}
+ local options = {}
+
+ for _, value in pairs(possibles) do
+ if value == initial_text then
+ table.insert(options, 1, t(value .. ' ') )
+ else
+ table.insert(options, t(value .. ' '))
+ end
+ end
+
+ return sn(nil, { c(1, options) })
+end
+
+local promo_property
+promo_property = function()
+ return sn(
+ nil,
+ c(1, {
+ -- Order is important, sn(...) first would cause infinite loop of expansion.
+ t(""),
+ sn(nil, {
+ t({ "", "\t" }),
+ d(1, visibility, {}, "private"),
+ i(2, '$var'),
+ t(","),
+ d(3, promo_property, {})
+ }),
+ })
+ )
+end
+
+ls.snippets = {
+ php = {
+ -- variable
+ s("v", {
+ t({ "/**", " * @var " }),
+ i(1, "types"),
+ t({""," */", "private $"}),
+ i(2, "name"),
+ t(";", ""),
+ }),
+
+ -- __construct
+ s("_c", {
+ d(1, visibility, {}),
+ t('function __construct('),
+ c(2, {
+ sn(nil, {
+ i(1, '$var'),
+ t({")", "{", "\t"}),
+ i(2, ''),
+ t({"", "}"}),
+ }),
+ sn(nil, {
+ d(1, promo_property, {}),
+ t({"",") {", "}"}),
+ }),
+ }),
+ }),
+
+ -- function
+ s("fn", {
+ d(1, visibility, {}, "public"),
+ t("function "),
+ i(2, "name"),
+ t("("),
+ i(3, "$arg"),
+ t(")"),
+ c(4, {
+ sn(nil, {
+ t(': '),
+ i(1, "void"),
+ }),
+ t(""),
+ }),
+ t({"", "{", ""}),
+ t("\t"), i(0, ""),
+ t({"", "}"})
+ }),
+
+ -- Route
+ s("ro", {
+ t("Route::"),
+ c(1, {
+ t("get"),
+ t("post"),
+ t("put"),
+ t("view"),
+ }),
+ t("('"),
+ i(2, "uri"),
+ t("', "),
+ c(3, {
+ sn(nil, {
+ t({'function () {', ' '}),
+ i(1, ''),
+ t({'', '});'}),
+ }),
+ sn(nil, {
+ t('['),
+ i(1, 'Controller'),
+ t('::class, \''),
+ i(2, 'method'),
+ t('\']);'),
+ })
+ }),
+ }),
+ }
+}
diff --git a/plugin/treesitter.vim b/lua/alpha/treesitter.lua
index b6bbd03..a88b6db 100644
--- a/plugin/treesitter.vim
+++ b/lua/alpha/treesitter.lua
@@ -1,5 +1,3 @@
-lua << EOF
-
require "nvim-treesitter.configs".setup {
highlight = {
enable = true,
@@ -50,5 +48,3 @@ require "nvim-treesitter.configs".setup {
},
}
}
-
-EOF
diff --git a/lua/plugins.lua b/lua/plugins.lua
index c0ab19a..e75d0fe 100644
--- a/lua/plugins.lua
+++ b/lua/plugins.lua
@@ -27,6 +27,7 @@ return require('packer').startup(function(use)
use 'tpope/vim-dispatch'
+ -- Completition
use "hrsh7th/nvim-cmp"
use "hrsh7th/cmp-buffer"
use "hrsh7th/cmp-path"
@@ -34,6 +35,9 @@ return require('packer').startup(function(use)
use "hrsh7th/cmp-nvim-lsp"
use "saadparwaiz1/cmp_luasnip"
use "onsails/lspkind-nvim"
+ use "hrsh7th/cmp-nvim-lsp-signature-help"
+ use "windwp/nvim-autopairs"
+
use "ray-x/lsp_signature.nvim"
diff --git a/plugin/alpha.vim b/plugin/alpha.vim
new file mode 100644
index 0000000..9a8969c
--- /dev/null
+++ b/plugin/alpha.vim
@@ -0,0 +1,13 @@
+if !exists('*alpha#save_and_exec')
+ function! alpha#save_and_exec() abort
+ if &filetype == 'vim'
+ :silent! write
+ :source %
+ elseif &filetype == 'lua'
+ :silent! write
+ :luafi %
+ endif
+
+ return
+ endfunction
+endif
diff --git a/plugin/keymap.vim b/plugin/keymap.vim
new file mode 100644
index 0000000..2e7f810
--- /dev/null
+++ b/plugin/keymap.vim
@@ -0,0 +1 @@
+nnoremap <leader><leader>x :call alpha#save_and_exec()<CR>
diff --git a/plugin/lsp.vim b/plugin/lsp.vim
index 82d9a8f..e69de29 100644
--- a/plugin/lsp.vim
+++ b/plugin/lsp.vim
@@ -1,43 +0,0 @@
-nnoremap <leader>vd :lua vim.lsp.buf.definition()<CR>
-nnoremap <leader>vsh :lua vim.lsp.buf.signature_help()<CR>
-nnoremap <leader>vh :lua vim.lsp.buf.hover()<CR>
-
-" to test
-nnoremap <leader>vi :lua vim.lsp.buf.implementation()<CR>
-nnoremap <leader>vf :lua vim.lsp.buf.formatting()<CR>
-nnoremap <leader>vrn :lua vim.lsp.buf.rename()<CR>
-nnoremap <leader>vca :lua vim.lsp.buf.code_action()<CR>
-nnoremap <leader>vsd :lua vim.lsp.util.show_line_diagnostics(); vim.lsp.util.show_line_diagnostics()<CR>
-nnoremap <leader>vn :lua vim.lsp.diagnostic.goto_next()<CR>
-
-nnoremap <leader>vo :LspRestart<CR>
-
-
-au Filetype php setl omnifunc=v:lua.vim.lsp.omnifunc
-autocmd FileType go setlocal omnifunc=v:lua.vim.lsp.omnifunc
-
-let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy']
-
-lua << EOF
-
-local function on_attach()
- vim.api.nvim_set_keymap('n', 'K', ':lua vim.lsp.buf.hover()<cr>', {noremap = true})
-
- require "lsp_signature".on_attach()
-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/plugin/plugins.vim b/plugin/plugins.vim
index f5df1c5..e69de29 100644
--- a/plugin/plugins.vim
+++ b/plugin/plugins.vim
@@ -1 +0,0 @@
-lua require('plugins')
diff --git a/plugin/sets.vim b/plugin/sets.vim
index 9a08a5c..d2e7599 100644
--- a/plugin/sets.vim
+++ b/plugin/sets.vim
@@ -12,6 +12,8 @@ set undofile
set undodir=~/.config/nvim/undodir
set nohlsearch
set incsearch
+set ignorecase
+set smartcase
set termguicolors
set scrolloff=8
set sidescrolloff=8
diff --git a/plugin/status.vim b/plugin/status.vim
deleted file mode 100644
index 9936f3e..0000000
--- a/plugin/status.vim
+++ /dev/null
@@ -1 +0,0 @@
-lua require("alpha.status-line")