1
0
Fork 0

bringing over updates from lunarvim and basic-ide

This commit is contained in:
Luca Bilke 2022-10-12 12:25:53 +02:00
parent 4d82798259
commit f51d7b2104
15 changed files with 358 additions and 121 deletions

View file

@ -4,16 +4,19 @@ require 'user.options'
require 'user.autocmds'
require 'user.theme'
require 'user.cmp'
require 'user.plugins.alpha'
require 'user.plugins.autopairs'
require 'user.plugins.bufferline'
require 'user.plugins.comment'
require 'user.plugins.gitsigns'
require 'user.plugins.impatient'
require 'user.plugins.indentline'
require 'user.plugins.lualine'
require 'user.plugins.nvim-tree'
require 'user.plugins.project'
require 'user.plugins.telescope'
require 'user.plugins.toggleterm'
require 'user.plugins.gitsigns'
require 'user.plugins.treesitter'
require 'user.plugins.autopairs'
require 'user.plugins.comment'
require 'user.plugins.nvim-tree'
require 'user.plugins.bufferline'
require 'user.plugins.lualine'
require 'user.plugins.toggleterm'
require 'user.plugins.project'
require 'user.plugins.impatient'
require 'user.plugins.illuminate'
require 'user.plugins.indentline'
require 'user.plugins.alpha'
require 'user.lsp'
require 'user.dap'

View file

@ -50,6 +50,15 @@ autocmds = {
command = "!cd ~/.local/src/dwmblocks/; sudo make install && { killall -q dwmblocks;setsid -f dwmblocks }"
}
},
{
"BufWritePost",
{
pattern = "*.java",
callback = function()
vim.lsp.codelens.refresh()
end
}
},
{
{ "BufDelete", "VimLeave" },
{
@ -69,15 +78,13 @@ autocmds = {
end
}
},
{ -- Remove statusline and tabline when in Alpha
'User',
{
'Filetype',
{
pattern = { "AlphaReady" },
pattern = { "gitcommit", "markdown" },
callback = function()
vim.cmd [[
set showtabline=0 | autocmd BufUnload <buffer> set showtabline=2
set laststatus=0 | autocmd BufUnload <buffer> set laststatus=3
]]
vim.opt_local.wrap = true
vim.opt_local.spell = true
end,
}
},
@ -88,6 +95,22 @@ autocmds = {
pattern = "plugins.lua",
command = "source <afile> | PackerCompile"
}
},
{ -- Fix auto comment
'BufWinEnter',
{
callback = function()
vim.cmd("set formatoptions-=cro")
end
}
},
{ -- Highlight yanked text
'TextYankPost',
{
callback = function()
vim.highlight.on_yank({ higroup = "Visual", timeout = 200 })
end
}
}
}

View file

@ -0,0 +1,56 @@
local dap_status_ok, dap = pcall(require, "dap")
if not dap_status_ok then
return
end
local dap_ui_status_ok, dapui = pcall(require, "dapui")
if not dap_ui_status_ok then
return
end
local dap_install_status_ok, dap_install = pcall(require, "dap-install")
if not dap_install_status_ok then
return
end
dap_install.setup {}
dap_install.config("python", {})
-- add other configs here
require('dapui').setup{
layouts = {
{
elements = {
'scopes',
'breakpoints',
'stacks',
'watches',
},
size = 40,
position = 'left',
},
{
elements = {
'repl',
'console',
},
size = 10,
position = 'bottom',
},
},
}
vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "DiagnosticSignError", linehl = "", numhl = "" })
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open()
end
dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close()
end
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close()
end

View file

@ -1,15 +0,0 @@
TODO: mason, lsp and dap setup
require('mason').setup({
ui = {
icons = {
package_installed = "✓",
package_pending = "➜",
package_uninstalled = "✗"
}
}
})
require("mason-lspconfig").setup({
ensure_installed = { "sumneko_lua", "bashls", "clangd" },
automatic_installation = false
})

View file

@ -2,91 +2,90 @@ local M = {}
local status_cmp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
if not status_cmp_ok then
return
return
end
local icons = require "icons"
M.capabilities = vim.lsp.protocol.make_client_capabilities()
M.capabilities.textDocument.completion.completionItem.snippetSupport = true
M.capabilities = cmp_nvim_lsp.update_capabilities(M.capabilities)
M.setup = function()
local signs = {
{ name = "DiagnosticSignError", text = icons.diagnostics.BoldError },
{ name = "DiagnosticSignWarn", text = icons.diagnostics.BoldWarning },
{ name = "DiagnosticSignHint", text = icons.diagnostics.BoldHint },
{ name = "DiagnosticSignInfo", text = icons.diagnostics.BoldInformation },
}
local signs = {
for _, sign in ipairs(signs) do
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
end
{ name = "DiagnosticSignError", text = "" },
{ name = "DiagnosticSignWarn", text = "" },
{ name = "DiagnosticSignHint", text = "" },
{ name = "DiagnosticSignInfo", text = "" },
}
local config = {
virtual_text = false, -- disable virtual text
signs = {
active = signs, -- show signs
},
update_in_insert = true,
underline = true,
severity_sort = true,
float = {
focusable = true,
style = "minimal",
border = "rounded",
source = "always",
header = "",
prefix = "",
},
}
for _, sign in ipairs(signs) do
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
end
vim.diagnostic.config(config)
local config = {
virtual_text = false, -- disable virtual text
signs = {
active = signs, -- show signs
},
update_in_insert = true,
underline = true,
severity_sort = true,
float = {
focusable = true,
style = "minimal",
border = "rounded",
source = "always",
header = "",
prefix = "",
},
}
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
border = "rounded",
})
vim.diagnostic.config(config)
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = "rounded",
})
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
border = "rounded",
})
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = "rounded",
})
end
local function lsp_keymaps(bufnr)
local opts = { noremap = true, silent = true }
local keymap = vim.api.nvim_buf_set_keymap
keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
keymap(bufnr, "n", "gI", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
keymap(bufnr, "n", "gl", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
keymap(bufnr, "n", "<leader>lf", "<cmd>lua vim.lsp.buf.formatting()<cr>", opts)
keymap(bufnr, "n", "<leader>li", "<cmd>LspInfo<cr>", opts)
keymap(bufnr, "n", "<leader>lI", "<cmd>LspInstallInfo<cr>", opts)
keymap(bufnr, "n", "<leader>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", opts)
keymap(bufnr, "n", "<leader>lj", "<cmd>lua vim.diagnostic.goto_next({buffer=0})<cr>", opts)
keymap(bufnr, "n", "<leader>lk", "<cmd>lua vim.diagnostic.goto_prev({buffer=0})<cr>", opts)
keymap(bufnr, "n", "<leader>lr", "<cmd>lua vim.lsp.buf.rename()<cr>", opts)
keymap(bufnr, "n", "<leader>ls", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
keymap(bufnr, "n", "<leader>lq", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
local opts = { noremap = true, silent = true }
local keymap = vim.api.nvim_buf_set_keymap
keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
keymap(bufnr, "n", "gI", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
keymap(bufnr, "n", "gl", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
keymap(bufnr, "n", "<leader>lf", "<cmd>lua vim.lsp.buf.format{ async = true }<cr>", opts)
keymap(bufnr, "n", "<leader>li", "<cmd>LspInfo<cr>", opts)
keymap(bufnr, "n", "<leader>lI", "<cmd>LspInstallInfo<cr>", opts)
keymap(bufnr, "n", "<leader>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", opts)
keymap(bufnr, "n", "<leader>lj", "<cmd>lua vim.diagnostic.goto_next({buffer=0})<cr>", opts)
keymap(bufnr, "n", "<leader>lk", "<cmd>lua vim.diagnostic.goto_prev({buffer=0})<cr>", opts)
keymap(bufnr, "n", "<leader>lr", "<cmd>lua vim.lsp.buf.rename()<cr>", opts)
keymap(bufnr, "n", "<leader>ls", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
keymap(bufnr, "n", "<leader>lq", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
end
M.on_attach = function(client, bufnr)
if client.name == "tsserver" then
client.resolved_capabilities.document_formatting = false
end
if client.name == "tsserver" then
client.server_capabilities.documentFormattingProvider = false
end
if client.name == "sumneko_lua" then
client.resolved_capabilities.document_formatting = false
end
if client.name == "sumneko_lua" then
client.server_capabilities.documentFormattingProvider = false
end
lsp_keymaps(bufnr)
local status_ok, illuminate = pcall(require, "illuminate")
if not status_ok then
return
end
illuminate.on_attach(client)
lsp_keymaps(bufnr)
local status_ok, illuminate = pcall(require, "illuminate")
if not status_ok then
return
end
illuminate.on_attach(client)
end
return M

View file

@ -0,0 +1,8 @@
local status_ok, _ = pcall(require, "lspconfig")
if not status_ok then
return
end
require "user.lsp.mason"
require("user.lsp.handlers").setup()
require "user.lsp.null-ls"

View file

@ -0,0 +1,43 @@
local servers = require('user.lsp.servers')
local settings = {
ui = {
border = "none",
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
},
log_level = vim.log.levels.INFO,
max_concurrent_installers = 4,
}
require("mason").setup(settings)
require("mason-lspconfig").setup({
ensure_installed = servers,
automatic_installation = true,
})
local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig")
if not lspconfig_status_ok then
return
end
local opts = {}
for _, server in pairs(servers) do
opts = {
on_attach = require("user.lsp.handlers").on_attach,
capabilities = require("user.lsp.handlers").capabilities,
}
server = vim.split(server, "@")[1]
local require_ok, conf_opts = pcall(require, "user.lsp.settings." .. server)
if require_ok then
opts = vim.tbl_deep_extend("force", conf_opts, opts)
end
lspconfig[server].setup(opts)
end

View file

@ -0,0 +1,11 @@
return {
"sumneko_lua",
"cssls",
"html",
"pyright",
"bashls",
"jsonls",
"yamlls",
"clangd",
"ansiblels",
}

View file

@ -67,12 +67,14 @@ return packer.startup(function(use)
use 'rafamadriz/friendly-snippets'
-- LSP/DAP
use 'williamboman/mason.nvim'
use 'mfussenegger/nvim-dap'
use 'jose-elias-alvarez/null-ls.nvim'
use 'neovim/nvim-lspconfig'
use 'williamboman/mason-lspconfig.nvim'
use 'mfussenegger/nvim-dap'
use 'rcarriga/nvim-dap-ui'
use 'ravenxrz/DAPInstall.nvim'
if packer_bootstrap then
require('packer').sync()
end
end)
end)

View file

@ -4,14 +4,30 @@ if not status_ok then
return
end
npairs.setup {
check_ts = true, -- treesitter integration
disable_filetype = { "TelescopePrompt" },
}
npairs.setup({
check_ts = true, -- treesitter integration
disable_filetype = { "TelescopePrompt" },
ts_config = {
lua = { "string", "source" },
javascript = { "string", "template_string" },
java = false,
},
fast_wrap = {
map = "<M-e>",
chars = { "{", "[", "(", '"', "'" },
pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""),
offset = 0, -- Offset from pattern match
end_key = "$",
keys = "qwertyuiopzxcvbnmasdfghjkl",
check_comma = true,
highlight = "PmenuSel",
highlight_grey = "LineNr",
},
})
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then
return
end
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done {})
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({}))

View file

@ -3,20 +3,27 @@ if not status_ok then
return
end
comment.setup {
comment.setup({
pre_hook = function(ctx)
local U = require "Comment.utils"
-- Only calculate commentstring for tsx filetypes
if vim.bo.filetype == "typescriptreact" then
local U = require("Comment.utils")
local location = nil
if ctx.ctype == U.ctype.block then
location = require("ts_context_commentstring.utils").get_cursor_location()
elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then
location = require("ts_context_commentstring.utils").get_visual_start_location()
-- Determine whether to use linewise or blockwise commentstring
local type = ctx.ctype == U.ctype.linewise and "__default" or "__multiline"
-- Determine the location where to calculate commentstring from
local location = nil
if ctx.ctype == U.ctype.blockwise then
location = require("ts_context_commentstring.utils").get_cursor_location()
elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then
location = require("ts_context_commentstring.utils").get_visual_start_location()
end
return require("ts_context_commentstring.internal").calculate_commentstring({
key = type,
location = location,
})
end
return require("ts_context_commentstring.internal").calculate_commentstring {
key = ctx.ctype == U.ctype.line and "__default" or "__multiline",
location = location,
}
end,
}
})

View file

@ -11,4 +11,26 @@ gitsigns.setup {
topdelete = { hl = "GitSignsDelete", text = "", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
changedelete = { hl = "GitSignsChange", text = "", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
},
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
watch_gitdir = {
interval = 1000,
follow_files = true,
},
attach_to_untracked = true,
current_line_blame_opts = {
virt_text = true,
virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align'
delay = 1000,
},
sign_priority = 6,
update_debounce = 100,
status_formatter = nil, -- Use default
preview_config = {
-- Options passed to nvim_open_win
border = "single",
style = "minimal",
relative = "cursor",
row = 0,
col = 1,
},
}

View file

@ -0,0 +1,38 @@
local status_ok, illuminate = pcall(require, "illuminate")
if not status_ok then
return
end
vim.g.Illuminate_ftblacklist = {'alpha', 'NvimTree'}
vim.api.nvim_set_keymap('n', '<a-n>', '<cmd>lua require"illuminate".next_reference{wrap=true}<cr>', {noremap=true})
vim.api.nvim_set_keymap('n', '<a-p>', '<cmd>lua require"illuminate".next_reference{reverse=true,wrap=true}<cr>', {noremap=true})
illuminate.configure {
providers = {
"lsp",
"treesitter",
"regex",
},
delay = 200,
filetypes_denylist = {
"dirvish",
"fugitive",
"alpha",
"NvimTree",
"packer",
"neogitstatus",
"Trouble",
"lir",
"Outline",
"spectre_panel",
"toggleterm",
"DressingSelect",
"TelescopePrompt",
},
filetypes_allowlist = {},
modes_denylist = {},
modes_allowlist = {},
providers_regex_syntax_denylist = {},
providers_regex_syntax_allowlist = {},
under_cursor = true,
}

View file

@ -1,12 +1,20 @@
local status_ok, treesitter = pcall(require, "nvim-treesitter")
if not status_ok then
return
end
local status_ok, configs = pcall(require, "nvim-treesitter.configs")
if not status_ok then
return
end
configs.setup({
ensure_installed = "all", -- one of "all" or a list of languages
ensure_installed = { "lua", "markdown", "markdown_inline", "bash", "python" }, -- put the language you want in this array
-- ensure_installed = "all", -- one of "all" or a list of languages
ignore_install = { "" }, -- List of parsers to ignore installing
highlight = {
sync_install = false, -- install languages synchronously (only applied to `ensure_installed`)
highlight = {
enable = true, -- false will disable the whole extension
disable = { "css" }, -- list of language that will be disabled
},
@ -14,4 +22,10 @@ configs.setup({
enable = true,
},
indent = { enable = true, disable = { "python", "css" } },
context_commentstring = {
enable = true,
enable_autocmd = false,
},
})

View file

@ -79,6 +79,11 @@ _G.packer_plugins = {
path = "/home/luca/.local/share/nvim/site/pack/packer/start/Comment.nvim",
url = "https://github.com/numToStr/Comment.nvim"
},
["DAPInstall.nvim"] = {
loaded = true,
path = "/home/luca/.local/share/nvim/site/pack/packer/start/DAPInstall.nvim",
url = "https://github.com/ravenxrz/DAPInstall.nvim"
},
LuaSnip = {
loaded = true,
path = "/home/luca/.local/share/nvim/site/pack/packer/start/LuaSnip",
@ -189,6 +194,11 @@ _G.packer_plugins = {
path = "/home/luca/.local/share/nvim/site/pack/packer/start/nvim-dap",
url = "https://github.com/mfussenegger/nvim-dap"
},
["nvim-dap-ui"] = {
loaded = true,
path = "/home/luca/.local/share/nvim/site/pack/packer/start/nvim-dap-ui",
url = "https://github.com/rcarriga/nvim-dap-ui"
},
["nvim-lspconfig"] = {
loaded = true,
path = "/home/luca/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",