feat: add lua-format to lsp
This commit is contained in:
parent
a893ddf25c
commit
b5489face8
3 changed files with 98 additions and 113 deletions
|
@ -52,6 +52,6 @@ vim.cmd([[
|
||||||
vim.g.coq_settings = {
|
vim.g.coq_settings = {
|
||||||
auto_start = "shut-up",
|
auto_start = "shut-up",
|
||||||
keymap = {
|
keymap = {
|
||||||
jump_to_mark = "", -- prevent <C-h> remapping
|
jump_to_mark = "" -- prevent <C-h> remapping
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|
157
lua/plugins.lua
157
lua/plugins.lua
|
@ -1,10 +1,13 @@
|
||||||
local fn = vim.fn
|
local fn = vim.fn
|
||||||
|
|
||||||
-- boostrap packer
|
-- boostrap packer
|
||||||
local install_path = fn.stdpath('data')..'/site/pack/packer/opt/packer.nvim'
|
local install_path = fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim'
|
||||||
local packer_bootstrap
|
local packer_bootstrap
|
||||||
if fn.empty(fn.glob(install_path)) > 0 then
|
if fn.empty(fn.glob(install_path)) > 0 then
|
||||||
packer_bootstrap = fn.system({'git', 'clone','https://github.com/wbthomason/packer.nvim', install_path})
|
packer_bootstrap = fn.system({
|
||||||
|
'git', 'clone', 'https://github.com/wbthomason/packer.nvim',
|
||||||
|
install_path
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- run PackerSync everytime plugins.lua is updated
|
-- run PackerSync everytime plugins.lua is updated
|
||||||
|
@ -19,94 +22,91 @@ vim.cmd([[packadd packer.nvim]])
|
||||||
|
|
||||||
-- initialize plugins
|
-- initialize plugins
|
||||||
return require('packer').startup(function(use)
|
return require('packer').startup(function(use)
|
||||||
-- let packer manage itself
|
-- let packer manage itself
|
||||||
use({'wbthomason/packer.nvim', opt = true})
|
use({'wbthomason/packer.nvim', opt = true})
|
||||||
|
|
||||||
-- theme
|
-- theme
|
||||||
use("ishan9299/nvim-solarized-lua")
|
use("ishan9299/nvim-solarized-lua")
|
||||||
|
|
||||||
-- commenting
|
-- commenting
|
||||||
use("tpope/vim-commentary")
|
use("tpope/vim-commentary")
|
||||||
|
|
||||||
-- session handling
|
-- session handling
|
||||||
use('tpope/vim-obsession')
|
use('tpope/vim-obsession')
|
||||||
use('dhruvasagar/vim-prosession')
|
use('dhruvasagar/vim-prosession')
|
||||||
|
|
||||||
-- status line
|
-- status line
|
||||||
use {
|
use {
|
||||||
'nvim-lualine/lualine.nvim',
|
'nvim-lualine/lualine.nvim',
|
||||||
requires = { 'kyazdani42/nvim-web-devicons', opt = true },
|
requires = {'kyazdani42/nvim-web-devicons', opt = true},
|
||||||
config = function()
|
config = function() require('lualine').setup() end
|
||||||
require('lualine').setup()
|
}
|
||||||
end
|
|
||||||
}
|
|
||||||
|
|
||||||
-- tabline
|
-- tabline
|
||||||
use {
|
use {
|
||||||
'kdheepak/tabline.nvim',
|
'kdheepak/tabline.nvim',
|
||||||
config = function()
|
config = function()
|
||||||
require'tabline'.setup {
|
require'tabline'.setup {
|
||||||
enable = true,
|
enable = true,
|
||||||
options = {
|
options = {show_filename_only = true}
|
||||||
show_filename_only = true,
|
}
|
||||||
}
|
end,
|
||||||
}
|
requires = {
|
||||||
end,
|
{'hoob3rt/lualine.nvim'},
|
||||||
requires = { { 'hoob3rt/lualine.nvim' }, {'kyazdani42/nvim-web-devicons', opt = true} }
|
{'kyazdani42/nvim-web-devicons', opt = true}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
-- blankline
|
-- blankline
|
||||||
use({
|
use({
|
||||||
"lukas-reineke/indent-blankline.nvim",
|
"lukas-reineke/indent-blankline.nvim",
|
||||||
config = function ()
|
config = function()
|
||||||
require("indent_blankline").setup {
|
require("indent_blankline").setup {
|
||||||
char = "┊",
|
char = "┊",
|
||||||
buftype_exclude = {"terminal", "help"}
|
buftype_exclude = {"terminal", "help"}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- git
|
-- git
|
||||||
use('tpope/vim-fugitive')
|
use('tpope/vim-fugitive')
|
||||||
use ({
|
use({
|
||||||
'lewis6991/gitsigns.nvim',
|
'lewis6991/gitsigns.nvim',
|
||||||
requires = {'nvim-lua/plenary.nvim'},
|
requires = {'nvim-lua/plenary.nvim'},
|
||||||
config = function() require('gitsigns').setup() end
|
config = function() require('gitsigns').setup() end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- autocompletion
|
-- autocompletion
|
||||||
use({
|
use({
|
||||||
"ms-jpq/coq_nvim",
|
"ms-jpq/coq_nvim",
|
||||||
branch="coq",
|
branch = "coq",
|
||||||
requires = {
|
requires = {{'ms-jpq/coq.artifacts', branch = 'artifacts'}}
|
||||||
{'ms-jpq/coq.artifacts', branch = 'artifacts'},
|
})
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
-- highlight current symbol
|
-- highlight current symbol
|
||||||
use({"RRethy/vim-illuminate"})
|
use({"RRethy/vim-illuminate"})
|
||||||
|
|
||||||
-- language server
|
-- language server
|
||||||
use({
|
use({
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
config = function() require("plugins.lspconfig") end,
|
config = function() require("plugins.lspconfig") end
|
||||||
})
|
})
|
||||||
|
|
||||||
use('williamboman/nvim-lsp-installer')
|
use('williamboman/nvim-lsp-installer')
|
||||||
|
|
||||||
-- treesitter
|
-- treesitter
|
||||||
use({
|
use({
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
config = function() require('plugins.treesitter') end,
|
config = function() require('plugins.treesitter') end,
|
||||||
run = ':TSUpdate'
|
run = ':TSUpdate'
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Telescope
|
-- Telescope
|
||||||
use({
|
use({
|
||||||
'nvim-telescope/telescope.nvim',
|
'nvim-telescope/telescope.nvim',
|
||||||
requires = {{'nvim-lua/plenary.nvim'}},
|
requires = {{'nvim-lua/plenary.nvim'}},
|
||||||
config = function() require('plugins.telescope') end,
|
config = function() require('plugins.telescope') end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- automatic pairs
|
-- automatic pairs
|
||||||
use({"Raimondi/delimitMate"})
|
use({"Raimondi/delimitMate"})
|
||||||
|
@ -118,22 +118,15 @@ return require('packer').startup(function(use)
|
||||||
use({
|
use({
|
||||||
"akinsho/nvim-toggleterm.lua",
|
"akinsho/nvim-toggleterm.lua",
|
||||||
config = function()
|
config = function()
|
||||||
require("toggleterm").setup({
|
require("toggleterm").setup({size = 32, open_mapping = [[<F4>]]})
|
||||||
size = 32,
|
end
|
||||||
open_mapping = [[<F4>]],
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- buffer closing
|
-- buffer closing
|
||||||
use({
|
use({"sar/bbye.nvim"})
|
||||||
"sar/bbye.nvim"
|
|
||||||
})
|
|
||||||
|
|
||||||
-- ansible filetype
|
-- ansible filetype
|
||||||
use({"pearofducks/ansible-vim"})
|
use({"pearofducks/ansible-vim"})
|
||||||
|
|
||||||
if packer_bootstrap then
|
if packer_bootstrap then require('packer').sync() end
|
||||||
require('packer').sync()
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -6,18 +6,8 @@ table.insert(nvim_runtime_path, "lua/?.lua")
|
||||||
table.insert(nvim_runtime_path, "lua/?/init.lua")
|
table.insert(nvim_runtime_path, "lua/?/init.lua")
|
||||||
|
|
||||||
local language_servers = {
|
local language_servers = {
|
||||||
"ansiblels",
|
"ansiblels", "bashls", "dockerls", "efm", "eslint", "html", "pyright",
|
||||||
"bashls",
|
"rust_analyzer", "sumneko_lua", "svelte", "taplo", "tsserver", "volar"
|
||||||
"dockerls",
|
|
||||||
"eslint",
|
|
||||||
"html",
|
|
||||||
"pyright",
|
|
||||||
"rust_analyzer",
|
|
||||||
"sumneko_lua",
|
|
||||||
"svelte",
|
|
||||||
"taplo",
|
|
||||||
"tsserver",
|
|
||||||
"volar",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, server_name in pairs(language_servers) do
|
for _, server_name in pairs(language_servers) do
|
||||||
|
@ -30,30 +20,31 @@ for _, server_name in pairs(language_servers) do
|
||||||
end
|
end
|
||||||
|
|
||||||
local extra_server_opts = {
|
local extra_server_opts = {
|
||||||
|
["efm"] = function(opts)
|
||||||
|
opts.filetypes = {"lua"}
|
||||||
|
opts.init_options = {documentFormatting = true}
|
||||||
|
opts.settings = {
|
||||||
|
rootMarkers = {".git/"},
|
||||||
|
languages = {
|
||||||
|
lua = {{formatCommand = "lua-format -i", formatStdin = true}}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end,
|
||||||
["sumneko_lua"] = function(opts)
|
["sumneko_lua"] = function(opts)
|
||||||
opts.settings = {
|
opts.settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
runtime = {
|
runtime = {version = 'LuaJIT', path = nvim_runtime_path},
|
||||||
version = 'LuaJIT',
|
diagnostics = {globals = {'vim'}},
|
||||||
path = nvim_runtime_path,
|
workspace = {library = vim.api.nvim_get_runtime_file("", true)},
|
||||||
},
|
telemetry = {enable = false}
|
||||||
diagnostics = {
|
}
|
||||||
globals = {'vim'},
|
|
||||||
},
|
|
||||||
workspace = {
|
|
||||||
library = vim.api.nvim_get_runtime_file("", true),
|
|
||||||
},
|
|
||||||
telemetry ={
|
|
||||||
enable = false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
local function custom_on_attach(client, buffer_nr)
|
local function custom_on_attach(client, buffer_nr)
|
||||||
-- onmifunc
|
-- onmifunc
|
||||||
vim.api.nvim_buf_set_option(0, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
vim.api.nvim_buf_set_option(buffer_nr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||||
|
|
||||||
-- Helper function
|
-- Helper function
|
||||||
local opts = {noremap = true, silent = true}
|
local opts = {noremap = true, silent = true}
|
||||||
|
@ -80,7 +71,8 @@ local function custom_on_attach(client, buffer_nr)
|
||||||
bufnnoremap("<C-p>", "<Cmd>lua vim.diagnostic.goto_prev()<CR>")
|
bufnnoremap("<C-p>", "<Cmd>lua vim.diagnostic.goto_prev()<CR>")
|
||||||
|
|
||||||
-- Show line diagnostics
|
-- Show line diagnostics
|
||||||
bufnnoremap("<leader>d", '<Cmd>lua vim.diagnostic.open_float(0, {scope = "line"})<CR>')
|
bufnnoremap("<leader>d",
|
||||||
|
'<Cmd>lua vim.diagnostic.open_float(0, {scope = "line"})<CR>')
|
||||||
|
|
||||||
-- Open local diagnostics in local list
|
-- Open local diagnostics in local list
|
||||||
bufnnoremap("<leader>D", "<Cmd>lua vim.diagnostic.setloclist()<CR>")
|
bufnnoremap("<leader>D", "<Cmd>lua vim.diagnostic.setloclist()<CR>")
|
||||||
|
@ -99,7 +91,7 @@ end
|
||||||
lsp_installer.on_server_ready(function(server)
|
lsp_installer.on_server_ready(function(server)
|
||||||
local opts = coq.lsp_ensure_capabilities({
|
local opts = coq.lsp_ensure_capabilities({
|
||||||
on_attach = custom_on_attach,
|
on_attach = custom_on_attach,
|
||||||
capabilities = vim.lsp.protocol.make_client_capabilities(),
|
capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
})
|
})
|
||||||
|
|
||||||
if extra_server_opts[server.name] then
|
if extra_server_opts[server.name] then
|
||||||
|
|
Loading…
Reference in a new issue