refactor(nvim): split plugin config
Split lua plugin configuration into separate files.
This commit is contained in:
parent
2d2a2e5490
commit
ab788203db
|
@ -1,105 +1,6 @@
|
|||
require('colorbuddy').colorscheme('gruvbuddy')
|
||||
require("colorbuddy").colorscheme("gruvbuddy")
|
||||
|
||||
-- TreeSitter
|
||||
|
||||
local configs = require'nvim-treesitter.configs'
|
||||
|
||||
configs.setup {
|
||||
context_commenting = {
|
||||
enable = true
|
||||
},
|
||||
ensure_installed = "maintained",
|
||||
highlight = {
|
||||
enable = true,
|
||||
}
|
||||
}
|
||||
|
||||
-- LSP
|
||||
local has_lsp, lspconfig = pcall(require, "lspconfig")
|
||||
|
||||
local servers = {
|
||||
ansiblels = true,
|
||||
bashls = true,
|
||||
cssls = true,
|
||||
html = true,
|
||||
|
||||
intelephense = {
|
||||
filetypes = { "install", "inc", "module", "php", "test", "theme" }
|
||||
},
|
||||
|
||||
tsserver = {
|
||||
filetypes = { "js", "jsx", "typescript", "vue" }
|
||||
},
|
||||
|
||||
yamlls = true,
|
||||
}
|
||||
|
||||
local setup_server = function(server, config)
|
||||
if not config then
|
||||
return
|
||||
end
|
||||
|
||||
if type(config) ~= "table" then
|
||||
config = {}
|
||||
end
|
||||
|
||||
lspconfig[server].setup(config)
|
||||
end
|
||||
|
||||
for server, config in pairs(servers) do
|
||||
setup_server(server, config)
|
||||
end
|
||||
|
||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
underline = true,
|
||||
virtual_text = false,
|
||||
signs = true,
|
||||
update_in_insert = true,
|
||||
}
|
||||
)
|
||||
|
||||
local key_mapper = function(mode, key, result)
|
||||
vim.api.nvim_set_keymap(
|
||||
mode,
|
||||
key,
|
||||
result,
|
||||
{noremap = true, silent = true}
|
||||
)
|
||||
end
|
||||
|
||||
key_mapper('n', '<c-k>', ':lua vim.lsp.buf.signature_help()<CR>')
|
||||
key_mapper('n', '<leader>af', ':lua vim.lsp.buf.code_action()<CR>')
|
||||
key_mapper('n', '<leader>dn', ':lua vim.lsp.diagnostic.goto_next()<CR>')
|
||||
key_mapper('n', '<leader>dp', ':lua vim.lsp.diagnostic.goto_prev()<CR>')
|
||||
key_mapper('n', '<leader>ds', ':lua vim.lsp.diagnostic.show_line_diagnostics()<CR>')
|
||||
key_mapper('n', '<leader>fb', ':lua require"telescope.builtin".buffers()<CR>')
|
||||
key_mapper('n', '<leader>fh', ':lua require"telescope.builtin".help_tags()<CR>')
|
||||
key_mapper('n', '<leader>fs', ':lua require"telescope.builtin".live_grep()<CR>')
|
||||
key_mapper('n', '<leader>rn', ':lua vim.lsp.buf.rename()<CR>')
|
||||
key_mapper('n', 'K', ':lua vim.lsp.buf.hover()<CR>')
|
||||
key_mapper('n', 'gD', ':lua vim.lsp.buf.declaration()<CR>')
|
||||
key_mapper('n', 'gW', ':lua vim.lsp.buf.workspace_symbol()<CR>')
|
||||
key_mapper('n', 'gd', ':lua vim.lsp.buf.definition()<CR>')
|
||||
key_mapper('n', 'gi', ':lua vim.lsp.buf.implementation()<CR>')
|
||||
key_mapper('n', 'gr', ':lua vim.lsp.buf.references()<CR>')
|
||||
key_mapper('n', 'gt', ':lua vim.lsp.buf.type_definition()<CR>')
|
||||
key_mapper('n', 'gw', ':lua vim.lsp.buf.document_symbol()<CR>')
|
||||
|
||||
vim.opt.termguicolors = true
|
||||
|
||||
vim.cmd [[highlight IndentBlanklineIndent6 guifg=#888888 gui=nocombine]]
|
||||
|
||||
vim.opt.list = true
|
||||
vim.opt.listchars = {
|
||||
eol = "↴",
|
||||
}
|
||||
|
||||
require("indent_blankline").setup {
|
||||
char_highlight_list = {
|
||||
"IndentBlanklineIndent1",
|
||||
},
|
||||
show_end_of_line = true,
|
||||
}
|
||||
|
||||
require 'opdavies.plugins.completion'
|
||||
require "opdavies.plugins.completion"
|
||||
require "opdavies.plugins.indent-blankline"
|
||||
require "opdavies.plugins.lsp"
|
||||
require "opdavies.plugins.treesitter"
|
||||
|
|
11
nvim/.config/nvim/lua/opdavies/plugins/indent-blankline.lua
Normal file
11
nvim/.config/nvim/lua/opdavies/plugins/indent-blankline.lua
Normal file
|
@ -0,0 +1,11 @@
|
|||
vim.opt.list = true
|
||||
vim.opt.listchars = {
|
||||
eol = "↴",
|
||||
}
|
||||
|
||||
require("indent_blankline").setup {
|
||||
char_highlight_list = {
|
||||
"IndentBlanklineIndent1",
|
||||
},
|
||||
show_end_of_line = true,
|
||||
}
|
70
nvim/.config/nvim/lua/opdavies/plugins/lsp.lua
Normal file
70
nvim/.config/nvim/lua/opdavies/plugins/lsp.lua
Normal file
|
@ -0,0 +1,70 @@
|
|||
local has_lsp, lspconfig = pcall(require, "lspconfig")
|
||||
|
||||
local servers = {
|
||||
ansiblels = true,
|
||||
bashls = true,
|
||||
cssls = true,
|
||||
html = true,
|
||||
|
||||
intelephense = {
|
||||
filetypes = { "install", "inc", "module", "php", "test", "theme" }
|
||||
},
|
||||
|
||||
tsserver = {
|
||||
filetypes = { "js", "jsx", "typescript", "vue" }
|
||||
},
|
||||
|
||||
yamlls = true,
|
||||
}
|
||||
|
||||
local setup_server = function(server, config)
|
||||
if not config then
|
||||
return
|
||||
end
|
||||
|
||||
if type(config) ~= "table" then
|
||||
config = {}
|
||||
end
|
||||
|
||||
lspconfig[server].setup(config)
|
||||
end
|
||||
|
||||
for server, config in pairs(servers) do
|
||||
setup_server(server, config)
|
||||
end
|
||||
|
||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
underline = true,
|
||||
virtual_text = false,
|
||||
signs = true,
|
||||
update_in_insert = true,
|
||||
}
|
||||
)
|
||||
|
||||
local key_mapper = function(mode, key, result)
|
||||
vim.api.nvim_set_keymap(
|
||||
mode,
|
||||
key,
|
||||
result,
|
||||
{noremap = true, silent = true}
|
||||
)
|
||||
end
|
||||
|
||||
key_mapper('n', '<c-k>', ':lua vim.lsp.buf.signature_help()<CR>')
|
||||
key_mapper('n', '<leader>af', ':lua vim.lsp.buf.code_action()<CR>')
|
||||
key_mapper('n', '<leader>dn', ':lua vim.lsp.diagnostic.goto_next()<CR>')
|
||||
key_mapper('n', '<leader>dp', ':lua vim.lsp.diagnostic.goto_prev()<CR>')
|
||||
key_mapper('n', '<leader>ds', ':lua vim.lsp.diagnostic.show_line_diagnostics()<CR>')
|
||||
key_mapper('n', '<leader>fb', ':lua require"telescope.builtin".buffers()<CR>')
|
||||
key_mapper('n', '<leader>fh', ':lua require"telescope.builtin".help_tags()<CR>')
|
||||
key_mapper('n', '<leader>fs', ':lua require"telescope.builtin".live_grep()<CR>')
|
||||
key_mapper('n', '<leader>rn', ':lua vim.lsp.buf.rename()<CR>')
|
||||
key_mapper('n', 'K', ':lua vim.lsp.buf.hover()<CR>')
|
||||
key_mapper('n', 'gD', ':lua vim.lsp.buf.declaration()<CR>')
|
||||
key_mapper('n', 'gW', ':lua vim.lsp.buf.workspace_symbol()<CR>')
|
||||
key_mapper('n', 'gd', ':lua vim.lsp.buf.definition()<CR>')
|
||||
key_mapper('n', 'gi', ':lua vim.lsp.buf.implementation()<CR>')
|
||||
key_mapper('n', 'gr', ':lua vim.lsp.buf.references()<CR>')
|
||||
key_mapper('n', 'gt', ':lua vim.lsp.buf.type_definition()<CR>')
|
||||
key_mapper('n', 'gw', ':lua vim.lsp.buf.document_symbol()<CR>')
|
11
nvim/.config/nvim/lua/opdavies/plugins/treesitter.lua
Normal file
11
nvim/.config/nvim/lua/opdavies/plugins/treesitter.lua
Normal file
|
@ -0,0 +1,11 @@
|
|||
local configs = require'nvim-treesitter.configs'
|
||||
|
||||
configs.setup {
|
||||
context_commenting = {
|
||||
enable = true
|
||||
},
|
||||
ensure_installed = "maintained",
|
||||
highlight = {
|
||||
enable = true,
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue