From 90348896f989719c7a956a327284e56e6e8b25b8 Mon Sep 17 00:00:00 2001 From: Nulo Date: Sat, 25 Sep 2021 00:19:15 -0300 Subject: [PATCH] Neovim --- .config/nvim/init.vim | 89 +++++++++++++++++++ .config/nvim/pack/plugins/start/cmp-buffer | 1 + .config/nvim/pack/plugins/start/cmp-nvim-lsp | 1 + .config/nvim/pack/plugins/start/nvim-cmp | 1 + .../nvim/pack/plugins/start/nvim-lspconfig | 1 + .../nvim/pack/plugins/start/vim-commentary | 1 + .config/nvim/pack/plugins/start/vim-sleuth | 1 + .config/nvim/pack/plugins/start/zig.vim | 1 + .gitmodules | 21 +++++ 9 files changed, 117 insertions(+) create mode 100644 .config/nvim/init.vim create mode 160000 .config/nvim/pack/plugins/start/cmp-buffer create mode 160000 .config/nvim/pack/plugins/start/cmp-nvim-lsp create mode 160000 .config/nvim/pack/plugins/start/nvim-cmp create mode 160000 .config/nvim/pack/plugins/start/nvim-lspconfig create mode 160000 .config/nvim/pack/plugins/start/vim-commentary create mode 160000 .config/nvim/pack/plugins/start/vim-sleuth create mode 160000 .config/nvim/pack/plugins/start/zig.vim create mode 100644 .gitmodules diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim new file mode 100644 index 0000000..2861e2f --- /dev/null +++ b/.config/nvim/init.vim @@ -0,0 +1,89 @@ +set mouse=a " Enable mouse +set linebreak " Wrap words +set hidden " Do not save when switching buffers +set inccommand=nosplit " Incremental live completion + +set ignorecase smartcase + +set updatetime=250 + +" Show trailing spaces and tabs +" set list listchars=lead:·,trail:·,tab:▷\ + +" exe 'set background='..readfile('/home/diablo/.theme')[0] +"let g:rose_pine_variant="moon" +set termguicolors +" colorscheme rose-pine +colorscheme selenized_bw + +" inoremap pumvisible() ? "\" : "\" +" set completeopt=menuone,noselect,preview +" autocmd CompleteDone * silent! pclose + +set completeopt=menu,menuone,noselect + +lua << EOF +local cmp = require'cmp' + +cmp.setup({ + snippet = { + expand = function(args) + end, + }, + mapping = { + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm({ select = true }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'buffer' }, + } +}) + + +local nvim_lsp = require('lspconfig') + +-- Use an on_attach function to only map the following keys +-- after the language server attaches to the current buffer +local on_attach = function(client, bufnr) + local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end + local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end + + -- Enable completion triggered by + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + local opts = { noremap=true, silent=true } + + -- See `:help vim.lsp.*` for documentation on any of the below functions + buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) + buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) + buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) + buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) + buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) + buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) + buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) + buf_set_keymap('n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) + buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) + buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) + buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()', opts) + +end + +local servers = { 'zls' } +for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { + on_attach = on_attach, + capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()), + } +end +EOF diff --git a/.config/nvim/pack/plugins/start/cmp-buffer b/.config/nvim/pack/plugins/start/cmp-buffer new file mode 160000 index 0000000..5dde543 --- /dev/null +++ b/.config/nvim/pack/plugins/start/cmp-buffer @@ -0,0 +1 @@ +Subproject commit 5dde5430757696be4169ad409210cf5088554ed6 diff --git a/.config/nvim/pack/plugins/start/cmp-nvim-lsp b/.config/nvim/pack/plugins/start/cmp-nvim-lsp new file mode 160000 index 0000000..246a41c --- /dev/null +++ b/.config/nvim/pack/plugins/start/cmp-nvim-lsp @@ -0,0 +1 @@ +Subproject commit 246a41c55668d5f84afcd805ee73b6e419375ae0 diff --git a/.config/nvim/pack/plugins/start/nvim-cmp b/.config/nvim/pack/plugins/start/nvim-cmp new file mode 160000 index 0000000..cc21a61 --- /dev/null +++ b/.config/nvim/pack/plugins/start/nvim-cmp @@ -0,0 +1 @@ +Subproject commit cc21a61910b89422122cc0c67a8265247bd0db6a diff --git a/.config/nvim/pack/plugins/start/nvim-lspconfig b/.config/nvim/pack/plugins/start/nvim-lspconfig new file mode 160000 index 0000000..3a22ac6 --- /dev/null +++ b/.config/nvim/pack/plugins/start/nvim-lspconfig @@ -0,0 +1 @@ +Subproject commit 3a22ac6f8d87d42f89b9de791053c98b803f1b6d diff --git a/.config/nvim/pack/plugins/start/vim-commentary b/.config/nvim/pack/plugins/start/vim-commentary new file mode 160000 index 0000000..349340d --- /dev/null +++ b/.config/nvim/pack/plugins/start/vim-commentary @@ -0,0 +1 @@ +Subproject commit 349340debb34f6302931f0eb7139b2c11dfdf427 diff --git a/.config/nvim/pack/plugins/start/vim-sleuth b/.config/nvim/pack/plugins/start/vim-sleuth new file mode 160000 index 0000000..38bd401 --- /dev/null +++ b/.config/nvim/pack/plugins/start/vim-sleuth @@ -0,0 +1 @@ +Subproject commit 38bd4010110614822cde523ebc5724963312ab63 diff --git a/.config/nvim/pack/plugins/start/zig.vim b/.config/nvim/pack/plugins/start/zig.vim new file mode 160000 index 0000000..fb534e7 --- /dev/null +++ b/.config/nvim/pack/plugins/start/zig.vim @@ -0,0 +1 @@ +Subproject commit fb534e7d12be7e529f79ad5ab99c08dc99f53294 diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5be5f10 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,21 @@ +[submodule ".config/nvim/pack/plugins/start/cmp-buffer"] + path = .config/nvim/pack/plugins/start/cmp-buffer + url = https://github.com/hrsh7th/cmp-buffer +[submodule ".config/nvim/pack/plugins/start/cmp-nvim-lsp"] + path = .config/nvim/pack/plugins/start/cmp-nvim-lsp + url = https://github.com/hrsh7th/cmp-nvim-lsp +[submodule ".config/nvim/pack/plugins/start/nvim-cmp"] + path = .config/nvim/pack/plugins/start/nvim-cmp + url = https://github.com/hrsh7th/nvim-cmp +[submodule ".config/nvim/pack/plugins/start/nvim-lspconfig"] + path = .config/nvim/pack/plugins/start/nvim-lspconfig + url = https://github.com/neovim/nvim-lspconfig +[submodule ".config/nvim/pack/plugins/start/vim-commentary"] + path = .config/nvim/pack/plugins/start/vim-commentary + url = https://tpope.io/vim/commentary.git +[submodule ".config/nvim/pack/plugins/start/vim-sleuth"] + path = .config/nvim/pack/plugins/start/vim-sleuth + url = https://github.com/tpope/vim-sleuth +[submodule ".config/nvim/pack/plugins/start/zig.vim"] + path = .config/nvim/pack/plugins/start/zig.vim + url = https://github.com/ziglang/zig.vim