finalyze neovim config

This commit is contained in:
vincent 2022-01-29 21:05:40 +01:00
parent 51ccf850ba
commit be8153969b
2 changed files with 141 additions and 11 deletions

View File

@ -7,7 +7,6 @@ vim.cmd([[
autocmd BufWritePost plugins.lua source <afile> | PackerCompile autocmd BufWritePost plugins.lua source <afile> | PackerCompile
augroup end augroup end
]]) ]])
------------- -------------
-- Options -- -- Options --
-- ---------- -- ----------
@ -19,9 +18,7 @@ vim.opt.smartcase = true
vim.opt.mouse = 'a' vim.opt.mouse = 'a'
vim.opt.background = 'dark' vim.opt.background = 'dark'
vim.opt.tabstop= 2 vim.opt.tabstop= 2
vim.opt.softtabstop = 2 vim.opt.softtabstop = 2 vim.opt.shiftwidth= 2 vim.opt.expandtab = true
vim.opt.shiftwidth= 2
vim.opt.expandtab = true
vim.opt.autoindent = true vim.opt.autoindent = true
vim.opt.copyindent= true vim.opt.copyindent= true
vim.opt.termguicolors = true vim.opt.termguicolors = true
@ -58,7 +55,7 @@ vim.api.nvim_set_keymap('i', 'kj','<esc>', {noremap = true})
vim.api.nvim_set_keymap('n', '<C-n>',':NvimTreeToggle<CR>', {noremap = true}) vim.api.nvim_set_keymap('n', '<C-n>',':NvimTreeToggle<CR>', {noremap = true})
vim.api.nvim_set_keymap('n', '<leader>r',':NvimTreeRefresh<CR>', {noremap = true}) vim.api.nvim_set_keymap('n', '<leader>r',':NvimTreeRefresh<CR>', {noremap = true})
vim.api.nvim_set_keymap('n', '<leader>n',':NvimTreeFindFile<CR>', {noremap = true}) vim.api.nvim_set_keymap('n', '<leader>n',':NvimTreeFindFile<CR>', {noremap = true})
vim.api.nvim_set_keymap('n', '<silent> <C-s>',':BufferPicleaderk<CR>', {noremap = true}) --vim.api.nvim_set_keymap('n', '<C-s>',':BufferLinePick<CR>', {noremap = true})
vim.api.nvim_set_keymap('c', 'w!!','w !sudo tee > /dev/null %', {noremap = true}) vim.api.nvim_set_keymap('c', 'w!!','w !sudo tee > /dev/null %', {noremap = true})
local cmp = require'cmp' 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 = 'ultisnips' }, -- For ultisnips users.
}, { }, {
{ name = 'buffer' }, { name = 'buffer' },
{ name = 'calc'},
}) })
}) })
@ -103,3 +101,10 @@ vim.api.nvim_set_keymap('c', 'w!!','w !sudo tee > /dev/null %', {noremap = true}
{ name = 'cmdline' } { 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"

View File

@ -74,6 +74,77 @@ return require('packer').startup {
} }
end 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 <c-x><c-o>
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', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
buf_set_keymap('n', '<space>=', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end
server:setup({
on_attach = on_attach()
})
vim.cmd [[ do User LspAttachBuffers ]]
end)
end
}
-- Autocomplete -- Autocomplete
use { use {
'hrsh7th/nvim-cmp', 'hrsh7th/nvim-cmp',
@ -85,6 +156,8 @@ return require('packer').startup {
'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-cmdline',
'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-path', 'hrsh7th/cmp-path',
'hrsh7th/cmp-calc',
-- snippets -- snippets
'SirVer/ultisnips', '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 -- File manager
use({ use({
"kyazdani42/nvim-tree.lua", "kyazdani42/nvim-tree.lua",
@ -121,16 +209,35 @@ return require('packer').startup {
use 'AckslD/nvim-whichkey-setup.lua' use 'AckslD/nvim-whichkey-setup.lua'
use 'famiu/feline.nvim'
use 'yamatsum/nvim-cursorline' use 'yamatsum/nvim-cursorline'
use 'freitass/todo.txt-vim' use 'freitass/todo.txt-vim'
use 'tpope/vim-fugitive' use {
'TimUntersberger/neogit',
requires = {
'nvim-lua/plenary.nvim'
},
keys = {
'<LEADER>gs'
},
cmd = {
'Neogit'
},
config = function()
require('neogit').setup {
disable_commit_confirmation = true,
disable_context_highlighting = true
}
vim.api.nvim_set_keymap('n', '<LEADER>gs', ':Neogit kind=split<CR>', {noremap = true})
end
}
use ({ use ({
'windwp/nvim-autopairs', 'windwp/nvim-autopairs',
config = function() config = function()
require('nvim-autopairs').setup{} require('nvim-autopairs').setup{
fast_wrap= {},
}
end end
}) })
@ -146,16 +253,34 @@ return require('packer').startup {
} }
end end
}) })
use { use {
'akinsho/nvim-bufferline.lua', 'akinsho/bufferline.nvim',
requires = { requires = {
'kyazdani42/nvim-web-devicons' 'kyazdani42/nvim-web-devicons'
}, },
config = function() 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', '<C-l>', ':BufferLineCycleNext<CR>', {noremap = true})
vim.api.nvim_set_keymap('n', '<C-h>', ':BufferLineCyclePrev<CR>', {noremap = true})
end end
} }
use 'romgrk/barbar.vim' use {'feline-nvim/feline.nvim',
config = function()
require('feline').setup({})
end
}
if packer_bootstrap then if packer_bootstrap then
require('packer').sync() require('packer').sync()
end end