diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index da9effe..dc0e066 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -7,7 +7,6 @@ vim.cmd([[ autocmd BufWritePost plugins.lua source | PackerCompile augroup end ]]) - ------------- -- Options -- -- ---------- @@ -19,9 +18,7 @@ vim.opt.smartcase = true vim.opt.mouse = 'a' vim.opt.background = 'dark' vim.opt.tabstop= 2 -vim.opt.softtabstop = 2 -vim.opt.shiftwidth= 2 -vim.opt.expandtab = true +vim.opt.softtabstop = 2 vim.opt.shiftwidth= 2 vim.opt.expandtab = true vim.opt.autoindent = true vim.opt.copyindent= true vim.opt.termguicolors = true @@ -58,7 +55,7 @@ vim.api.nvim_set_keymap('i', 'kj','', {noremap = true}) vim.api.nvim_set_keymap('n', '',':NvimTreeToggle', {noremap = true}) vim.api.nvim_set_keymap('n', 'r',':NvimTreeRefresh', {noremap = true}) vim.api.nvim_set_keymap('n', 'n',':NvimTreeFindFile', {noremap = true}) -vim.api.nvim_set_keymap('n', ' ',':BufferPicleaderk', {noremap = true}) +--vim.api.nvim_set_keymap('n', '',':BufferLinePick', {noremap = true}) vim.api.nvim_set_keymap('c', 'w!!','w !sudo tee > /dev/null %', {noremap = true}) local cmp = require'cmp' @@ -85,6 +82,7 @@ vim.api.nvim_set_keymap('c', 'w!!','w !sudo tee > /dev/null %', {noremap = true} { name = 'ultisnips' }, -- For ultisnips users. }, { { name = 'buffer' }, + { name = 'calc'}, }) }) @@ -103,3 +101,10 @@ vim.api.nvim_set_keymap('c', 'w!!','w !sudo tee > /dev/null %', {noremap = true} { name = 'cmdline' } }) }) + + -- If you want insert `(` after select function or method item +local cmp_autopairs = require('nvim-autopairs.completion.cmp') +local cmp = require('cmp') +cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) +-- add a lisp filetype (wrap my-function), FYI: Hardcoded = { "clojure", "clojurescript", "fennel", "janet" } +cmp_autopairs.lisp[#cmp_autopairs.lisp+1] = "racket" diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index 55a7ed9..b2cff06 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -74,6 +74,77 @@ return require('packer').startup { } end } + -- Language server protocol + use { + 'williamboman/nvim-lsp-installer', + requires = { + 'neovim/nvim-lspconfig', + }, + run = function() + local required_servers = { + "ansiblels", + "bashls", + "diagnosticls", + "dockerls", + "jsonls", + "pylsp", + "pyright", + "sqls", + "yamlls", + "remark_ls", + } + + require "nvim-lsp-installer.ui.status-win"().open() + local lsp_installer_servers = require'nvim-lsp-installer.servers' + for _, required_server in pairs(required_servers) do + local _, server = lsp_installer_servers.get_server(required_server) + if not server:is_installed() then + server:install() + end + end + end, + config = function() + local lsp_installer = require("nvim-lsp-installer") + + lsp_installer.on_server_ready(function(server) + 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', '=', 'lua vim.lsp.buf.formatting()', opts) + end + + server:setup({ + on_attach = on_attach() + }) + + vim.cmd [[ do User LspAttachBuffers ]] + end) + end + } -- Autocomplete use { 'hrsh7th/nvim-cmp', @@ -85,6 +156,8 @@ return require('packer').startup { 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-path', + 'hrsh7th/cmp-calc', + -- snippets 'SirVer/ultisnips', @@ -93,6 +166,21 @@ return require('packer').startup { } } + use({'jose-elias-alvarez/null-ls.nvim', + config= function() + require("null-ls").setup({ + sources = { + require("null-ls").builtins.formatting.prettier, + require("null-ls").builtins.formatting.trim_whitespace, + require("null-ls").builtins.formatting.trim_newlines, + require("null-ls").builtins.formatting.black, + require("null-ls").builtins.diagnostics.eslint, + require("null-ls").builtins.diagnostics.ansiblelint, + require("null-ls").builtins.completion.spell, + }, + }) + end}) + -- File manager use({ "kyazdani42/nvim-tree.lua", @@ -121,16 +209,35 @@ return require('packer').startup { use 'AckslD/nvim-whichkey-setup.lua' - use 'famiu/feline.nvim' use 'yamatsum/nvim-cursorline' use 'freitass/todo.txt-vim' - use 'tpope/vim-fugitive' + use { + 'TimUntersberger/neogit', + requires = { + 'nvim-lua/plenary.nvim' + }, + keys = { + 'gs' + }, + cmd = { + 'Neogit' + }, + config = function() + require('neogit').setup { + disable_commit_confirmation = true, + disable_context_highlighting = true + } + vim.api.nvim_set_keymap('n', 'gs', ':Neogit kind=split', {noremap = true}) + end + } use ({ 'windwp/nvim-autopairs', config = function() - require('nvim-autopairs').setup{} + require('nvim-autopairs').setup{ + fast_wrap= {}, + } end }) @@ -146,16 +253,34 @@ return require('packer').startup { } end }) + use { - 'akinsho/nvim-bufferline.lua', + 'akinsho/bufferline.nvim', requires = { 'kyazdani42/nvim-web-devicons' }, config = function() - require("bufferline").setup({}) + require('bufferline').setup{ + options = { + offsets = { + { + filetype = 'NvimTree', + text = 'File Explorer', + highlight = 'Directory', + text_align = 'left' + } + } + } + } + vim.api.nvim_set_keymap('n', '', ':BufferLineCycleNext', {noremap = true}) + vim.api.nvim_set_keymap('n', '', ':BufferLineCyclePrev', {noremap = true}) end } - use 'romgrk/barbar.vim' + use {'feline-nvim/feline.nvim', + config = function() + require('feline').setup({}) + end + } if packer_bootstrap then require('packer').sync() end