feat: added luacheckrc for pre commit luacheck

feat: added nvim conf for scala lsp
This commit is contained in:
Patrick Großmann 2023-05-11 13:39:54 +09:00
parent 935744693a
commit dc5d5031c4
Signed by: patrick
GPG key ID: 451F95EFB8BECD0F
2 changed files with 122 additions and 49 deletions

68
.luacheckrc Normal file
View file

@ -0,0 +1,68 @@
files["data/nvim/**/*.lua"] = {
read_globals = {
vim = {
fields = {
api = {
other_fields = true,
read_only = true,
},
cmd = {
other_fields = true,
read_only = true,
},
defer_fn = {
read_only = true,
},
diagnostic = {
other_fields = true,
read_only = true,
},
fn = {
other_fields = true,
read_only = true,
},
fs = {
other_fields = true,
read_only = true,
},
g = {
other_fields = true,
read_only = false,
},
keymap = {
other_fields = true,
read_only = true,
},
loop = {
other_fields = true,
read_only = true,
},
lsp = {
fields = {
handlers = {
other_fields = true,
read_only = false,
}
},
other_fields = true,
read_only = true,
},
notify = {
read_only = false,
},
o = {
other_fields = true,
read_only = false,
},
opt = {
other_fields = true,
read_only = false,
},
v = {
other_fields = true,
read_only = true,
},
},
},
},
}

View file

@ -10,11 +10,11 @@ local format = function(opts)
vim_item.menu = opts.menu[entry.source.name]
end
if entry.source.name == 'cmp_tabnine' then
if entry.source.name == "cmp_tabnine" then
if entry.completion_item.data ~= nil and entry.completion_item.data.detail ~= nil then
vim_item.menu = entry.completion_item.data.detail .. ' ' .. vim_item.menu
vim_item.menu = entry.completion_item.data.detail .. " " .. vim_item.menu
end
vim_item.kind = ''
vim_item.kind = ""
end
if opts.maxwidth ~= nil then
@ -47,34 +47,33 @@ return {
config = function()
local lspconfig = require("lspconfig")
local capabilities = require("cmp_nvim_lsp").default_capabilities()
lspconfig.bashls.setup { capabilities = capabilities, }
lspconfig.clangd.setup { capabilities = capabilities, }
lspconfig.cmake.setup { capabilities = capabilities, }
lspconfig.gopls.setup { capabilities = capabilities, }
lspconfig.hls.setup { capabilities = capabilities, }
lspconfig.lua_ls.setup { capabilities = capabilities, }
lspconfig.texlab.setup { capabilities = capabilities, }
lspconfig.nil_ls.setup { capabilities = capabilities, }
lspconfig.pyright.setup { capabilities = capabilities, }
lspconfig.rust_analyzer.setup { capabilities = capabilities, }
lspconfig.zls.setup { capabilities = capabilities, }
lspconfig.bashls.setup({ capabilities = capabilities })
lspconfig.clangd.setup({ capabilities = capabilities })
lspconfig.cmake.setup({ capabilities = capabilities })
lspconfig.gopls.setup({ capabilities = capabilities })
lspconfig.hls.setup({ capabilities = capabilities })
lspconfig.lua_ls.setup({ capabilities = capabilities })
lspconfig.texlab.setup({ capabilities = capabilities })
lspconfig.nil_ls.setup({ capabilities = capabilities })
lspconfig.pyright.setup({ capabilities = capabilities })
lspconfig.rust_analyzer.setup({ capabilities = capabilities })
lspconfig.zls.setup({ capabilities = capabilities })
lspconfig.metals.setup({ capabilities = capabilities })
local map = vim.keymap.set
local opts = {noremap = true, silent = true}
map('n', "<leader>l", vim.diagnostic.open_float, opts)
map('n', 'gd', vim.lsp.buf.definition, opts)
map('n', '<leader>r', vim.lsp.buf.rename, opts)
map('n', '<leader>f', vim.lsp.buf.format, opts)
map('n', '<leader>a', vim.lsp.buf.code_action, opts)
local opts = { noremap = true, silent = true }
map("n", "<leader>l", vim.diagnostic.open_float, opts)
map("n", "gd", vim.lsp.buf.definition, opts)
map("n", "<leader>r", vim.lsp.buf.rename, opts)
map("n", "<leader>f", vim.lsp.buf.format, opts)
map("n", "<leader>a", vim.lsp.buf.code_action, opts)
end,
},
{
'kosayoda/nvim-lightbulb',
dependencies = 'antoinemadec/FixCursorHold.nvim',
opts = {autocmd = {enabled = true}},
"kosayoda/nvim-lightbulb",
dependencies = "antoinemadec/FixCursorHold.nvim",
opts = { autocmd = { enabled = true } },
},
{
"hrsh7th/nvim-cmp",
@ -97,27 +96,27 @@ return {
config = true,
},
{
'tzachar/cmp-tabnine',
build = './install.sh',
"tzachar/cmp-tabnine",
build = "./install.sh",
},
},
config = function()
local cmp = require("cmp")
cmp.setup({
sources = {
{ name = 'luasnip' },
{ name = 'cmp_tabnine' },
{ name = 'nvim_lsp_signature_help' },
{ name = 'nvim_lsp' },
{ name = 'buffer' },
{ name = 'async_path' },
{ name = 'calc' },
{ name = 'emoji' },
{ name = 'nvim_lua' },
{ name = "luasnip" },
{ name = "cmp_tabnine" },
{ name = "nvim_lsp_signature_help" },
{ name = "nvim_lsp" },
{ name = "buffer" },
{ name = "async_path" },
{ name = "calc" },
{ name = "emoji" },
{ name = "nvim_lua" },
},
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
require("luasnip").lsp_expand(args.body)
end,
},
-- add lspkind pictograms
@ -134,17 +133,20 @@ return {
nvim_lsp = "[LSP]",
nvim_lua = "[Lua]",
path = "[Path]",
}
},
}),
},
mapping = {
['<CR>'] = cmp.mapping.confirm({ select = false }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c'}),
["<CR>"] = cmp.mapping.confirm({ select = false }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<Tab>"] = require("cmp").mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "")
vim.fn.feedkeys(
vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true),
""
)
else
fallback()
end
@ -153,7 +155,10 @@ return {
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true), "")
vim.fn.feedkeys(
vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true),
""
)
else
fallback()
end
@ -164,18 +169,18 @@ return {
init = function()
local cmp = require("cmp")
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({ '/', '?'}, {
cmp.setup.cmdline({ "/", "?" }, {
sources = {
{ name = 'buffer' }
}
{ name = "buffer" },
},
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
cmp.setup.cmdline(":", {
sources = {
{ name = 'path' },
{ name = 'cmdline' }
}
{ name = "path" },
{ name = "cmdline" },
},
})
end,
},