Update nvim plugins

master
Ian Mancini 3 years ago
parent 89ef9a303c
commit 75a972df9d

@ -1,9 +1,14 @@
local get_buffer_name = function()
-- Prevent glob expansion on weird filenames
return "'" .. vim.api.nvim_buf_get_name(0) .. "'"
end
local prettier = function() local prettier = function()
return { return {
exe = "prettier", exe = "prettier",
args = { args = {
"--stdin-filepath", vim.api.nvim_buf_get_name(0), '--single-quote', "--stdin-filepath", get_buffer_name(), '--single-quote',
'--no-semi' '--no-semi', '--prose-wrap', 'always'
}, },
stdin = true stdin = true
} }
@ -12,7 +17,7 @@ end
local black = function() local black = function()
return { return {
exe = "black", exe = "black",
args = {"-q", "--stdin-filename", vim.api.nvim_buf_get_name(0), "-"}, args = {"-q", "--stdin-filename", get_buffer_name(), "-"},
stdin = true stdin = true
} }
end end
@ -20,33 +25,19 @@ end
local clang_format = function() local clang_format = function()
return { return {
exe = "clang-format", exe = "clang-format",
args = {"--assume-filename", vim.api.nvim_buf_get_name(0)}, args = {"--assume-filename", get_buffer_name()},
stdin = true, stdin = true,
cwd = vim.fn.expand('%:p:h') cwd = vim.fn.expand('%:p:h')
} }
end end
local gofmt = function() local gofmt = function() return {exe = "gofmt", stdin = true} end
return {
exe = "gofmt",
stdin = true
}
end
local blade_formatter = function() local blade_formatter = function()
return { return {exe = "blade-formatter", args = {"--stdin"}, stdin = true}
exe = "blade-formatter",
args = {"--stdin"},
stdin = true
}
end end
local lua_formatter = function() local lua_formatter = function() return {exe = "lua-format", stdin = true} end
return {
exe = "lua-format",
stdin = true
}
end
require('formatter').setup({ require('formatter').setup({
logging = false, logging = false,
@ -62,6 +53,7 @@ require('formatter').setup({
php = {prettier}, php = {prettier},
css = {prettier}, css = {prettier},
html = {prettier}, html = {prettier},
yaml = {prettier},
python = {black}, python = {black},
lua = {lua_formatter} lua = {lua_formatter}
} }
@ -70,6 +62,6 @@ require('formatter').setup({
vim.api.nvim_exec([[ vim.api.nvim_exec([[
augroup FormatAutogroup augroup FormatAutogroup
autocmd! autocmd!
autocmd BufWritePost *.c,*.h,*.cpp,*.go,*.html,*.css,*.js,*.ts,*.jsx,*.tsx,*.py,*.blade.php,*.php,*.lua FormatWrite autocmd BufWritePost *.c,*.h,*.cpp,*.go,*.html,*.css,*.js,*.ts,*.jsx,*.tsx,*.py,*.blade.php,*.php,*.lua,*.yaml,*.yml FormatWrite
augroup END augroup END
]], true) ]], true)

@ -12,21 +12,13 @@ return require('packer').startup(function()
} }
-- File explorer -- File explorer
use { use {'kevinhwang91/rnvimr', config = [[require('plugins.rnvimr')]]}
'kevinhwang91/rnvimr',
config = [[require('plugins.rnvimr')]]
}
use { use {'kyazdani42/nvim-tree.lua', config = [[require('plugins.nvim-tree')]]}
'kyazdani42/nvim-tree.lua',
config = [[require('plugins.nvim-tree')]]
}
-- LSP config -- LSP config
use { use {'neovim/nvim-lspconfig', config = [[require('plugins.lsp')]]}
'neovim/nvim-lspconfig', use {'williamboman/nvim-lsp-installer'}
config = [[require('plugins.lsp')]]
}
-- Langugage specific LSP plugins -- Langugage specific LSP plugins
use {'tjdevries/nlua.nvim'} use {'tjdevries/nlua.nvim'}
@ -46,10 +38,7 @@ return require('packer').startup(function()
use {'stevearc/aerial.nvim'} use {'stevearc/aerial.nvim'}
-- Diagnostics -- Diagnostics
use { use {'folke/trouble.nvim', config = [[require('plugins.trouble-nvim')]]}
'folke/trouble.nvim',
config = [[require('plugins.trouble-nvim')]]
}
-- Tree-sitter -- Tree-sitter
use { use {
@ -69,10 +58,7 @@ return require('packer').startup(function()
} }
-- Completion -- Completion
use { use {'hrsh7th/nvim-compe', config = [[require('plugins.nvim-compe')]]}
'hrsh7th/nvim-compe',
config = [[require('plugins.nvim-compe')]]
}
-- Snippets -- Snippets
use {'hrsh7th/vim-vsnip'} use {'hrsh7th/vim-vsnip'}
@ -91,10 +77,7 @@ return require('packer').startup(function()
config = [[require('plugins.gitsigns-nvim')]] config = [[require('plugins.gitsigns-nvim')]]
} }
use {'tpope/vim-fugitive'} use {'tpope/vim-fugitive'}
use { use {'kdheepak/lazygit.nvim', config = [[require('plugins.lazygit-nvim')]]}
'kdheepak/lazygit.nvim',
config = [[require('plugins.lazygit-nvim')]]
}
-- Indent lines -- Indent lines
use { use {
@ -118,10 +101,7 @@ return require('packer').startup(function()
use { use {
'hoob3rt/lualine.nvim', 'hoob3rt/lualine.nvim',
requires = { requires = {'kyazdani42/nvim-web-devicons', opt = true},
'kyazdani42/nvim-web-devicons',
opt = true
},
config = [[require('plugins.lualine')]] config = [[require('plugins.lualine')]]
} }
@ -132,10 +112,7 @@ return require('packer').startup(function()
use {'norcalli/nvim-colorizer.lua'} use {'norcalli/nvim-colorizer.lua'}
-- Colorschemes -- Colorschemes
use { use {'Th3Whit3Wolf/onebuddy', requires = {'tjdevries/colorbuddy.vim'}}
'Th3Whit3Wolf/onebuddy',
requires = {'tjdevries/colorbuddy.vim'}
}
use {'RRethy/nvim-base16'} use {'RRethy/nvim-base16'}
use {'NTBBloodbath/doom-one.nvim'} use {'NTBBloodbath/doom-one.nvim'}
use {'folke/tokyonight.nvim'} use {'folke/tokyonight.nvim'}
@ -151,10 +128,7 @@ return require('packer').startup(function()
} }
-- Python -- Python
use { use {'petobens/poet-v', config = [[require('plugins.poet-v')]]}
'petobens/poet-v',
config = [[require('plugins.poet-v')]]
}
-- Blade -- Blade
use {'Eduruiz/vim-blade'} use {'Eduruiz/vim-blade'}

@ -2,18 +2,12 @@ local lsp = require("lspconfig")
local aerial = require("aerial") local aerial = require("aerial")
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.handlers["textDocument/publishDiagnostics"] =
vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics,
signs = true, {signs = true, virtual_text = true, underline = true})
virtual_text = true,
underline = true
})
local noremap = function(lhs, rhs, mode) local noremap = function(lhs, rhs, mode)
mode = mode or 'n' mode = mode or 'n'
local opts = { local opts = {noremap = true, silent = true}
noremap = true,
silent = true
}
vim.api.nvim_buf_set_keymap(0, mode, lhs, rhs, opts) vim.api.nvim_buf_set_keymap(0, mode, lhs, rhs, opts)
end end
@ -23,9 +17,7 @@ local set_lsp_config = function(client, bufnr)
aerial.on_attach(client) aerial.on_attach(client)
local mappings = { local mappings = {
v = { v = {['<leader>ca'] = '<cmd><C-U>Lspsaga range_code_action<CR'},
['<leader>ca'] = '<cmd><C-U>Lspsaga range_code_action<CR'
},
n = { n = {
['gD'] = '<cmd>lua vim.lsp.buf.declaration()<CR>', ['gD'] = '<cmd>lua vim.lsp.buf.declaration()<CR>',
['gd'] = '<cmd>lua vim.lsp.buf.definition()<CR>', ['gd'] = '<cmd>lua vim.lsp.buf.definition()<CR>',
@ -53,25 +45,37 @@ local set_lsp_config = function(client, bufnr)
end end
end end
local lsp_installer = require("nvim-lsp-installer")
lsp_installer.on_server_ready(function(server)
local opts = {}
if server.name == "tailwindcss" then
opts.handlers = {
["tailwindcss/getConfiguration"] = function(_, _, params, _, bufnr,
_)
vim.lsp.buf_notify(bufnr,
"tailwindcss/getConfigurationResponse",
{_id = params._id})
end
}
end
server:setup(opts)
vim.cmd [[ do User LspAttachBuffers ]]
end)
-- Lua -- Lua
require('nlua.lsp.nvim').setup(lsp, { require('nlua.lsp.nvim').setup(lsp, {on_attach = set_lsp_config})
on_attach = set_lsp_config
})
-- C/C++ -- C/C++
lsp.clangd.setup { lsp.clangd.setup {on_attach = set_lsp_config}
on_attach = set_lsp_config
}
-- Golang -- Golang
lsp.gopls.setup { lsp.gopls.setup {on_attach = set_lsp_config}
on_attach = set_lsp_config
}
-- PHP -- PHP
lsp.phpactor.setup { lsp.phpactor.setup {on_attach = set_lsp_config}
on_attach = set_lsp_config
}
-- Typescript -- Typescript
lsp.tsserver.setup { lsp.tsserver.setup {
@ -82,9 +86,7 @@ lsp.tsserver.setup {
} }
-- Python -- Python
lsp.pyright.setup { lsp.pyright.setup {on_attach = set_lsp_config}
on_attach = set_lsp_config
}
local eslint = { local eslint = {
lintCommand = "eslint_d -f unix --stdin --stdin-filename ${INPUT}", lintCommand = "eslint_d -f unix --stdin --stdin-filename ${INPUT}",
@ -101,10 +103,7 @@ local flake8 = {
lintFormats = {"%f:%l:%c: %m"} lintFormats = {"%f:%l:%c: %m"}
} }
local isort = { local isort = {formatCommand = "isort --profile black -", formatStdin = true}
formatCommand = "isort --profile black -",
formatStdin = true
}
local phpstan = { local phpstan = {
lintCommand = "./vendor/bin/phpstan analyze --error-format raw --no-progress" lintCommand = "./vendor/bin/phpstan analyze --error-format raw --no-progress"

@ -6,17 +6,12 @@ require("toggleterm").setup {
start_in_insert = true, start_in_insert = true,
direction = 'float', direction = 'float',
close_on_exit = false, close_on_exit = false,
float_opts = { float_opts = {winblend = 0, border = 'single'}
winblend = 0,
border = 'single'
}
} }
function _G.set_terminal_keymaps() function _G.set_terminal_keymaps()
local opts = { local opts = {noremap = true}
noremap = true
}
vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts) vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts)
end end
vim.cmd('autocmd! TermOpen term://(*toggleterm#* lua set_terminal_keymaps()') vim.cmd('autocmd! TermOpen term://*toggleterm#* lua set_terminal_keymaps()')

Loading…
Cancel
Save