commit cb231f9febf9fd19bca52a5a071a91297c71e3f5
parent 33e218e068b9b2dd9e43876658789f1aaa13a126
Author: Thomas Vigouroux <thomas.vigouroux@protonmail.com>
Date: Mon, 25 Jul 2022 09:56:44 +0200
Update
Diffstat:
5 files changed, 110 insertions(+), 84 deletions(-)
diff --git a/init.lua b/init.lua
@@ -6,7 +6,7 @@ local M = {}
-- imp.enable_profile()
-- end
-require "plugins" -- Load all plugins
+require "plugins" -- Load all plugins
vim.g.python_host_prog = "/bin/python"
vim.g.oak_statusline = 1
@@ -18,7 +18,6 @@ elseif jit.os == "Darwin" then
end
local o = vim.opt
-
o.number = true
o.relativenumber = true
o.showmode = false
@@ -31,11 +30,10 @@ o.spelllang = { "en", "fr" }
o.spellfile = vim.fn.stdpath("config") .. "/spell/correct.UTF-8.add"
o.textwidth = 100
o.colorcolumn = "+0"
-o.signcolumn = "number"
+o.signcolumn = "yes:1"
o.scrolloff = 5
o.winblend = 10
o.updatetime = 500
-o.wrap = false
o.cursorline = false
o.mouse = "n"
o.previewheight = 10
@@ -52,12 +50,12 @@ o.inccommand = "nosplit"
o.completeopt = { "preview", "menuone", "noinsert" }
o.list = true
o.listchars = {
- tab = "|-",
- trail = "•",
- nbsp = "!",
- conceal = ":",
- precedes = "<",
- extends = ">"
+ tab = "|-",
+ trail = "•",
+ nbsp = "!",
+ conceal = ":",
+ precedes = "<",
+ extends = ">"
}
o.tags = ".tags;/"
o.undofile = true
@@ -80,10 +78,16 @@ o.sessionoptions:remove "buffers"
vim.g.mapleader = " "
vim.g.maplocalleader = "&"
-vim.cmd [[au TextYankPost * silent! lua vim.highlight.on_yank{higroup="Visual", timeout=250}]]
+vim.api.nvim_create_autocmd("TextYankPost", {
+ silent = true,
+ callback = function()
+ vim.highlight.on_yank { higroup = "Visual", timeout = 250 }
+ end
+})
vim.cmd [[language en_US.utf8]]
vim.cmd [[language time POSIX]]
-vim.cmd [[colorscheme oak]]
+vim.cmd.packadd "termdebug"
+vim.cmd.colorscheme "oak"
-- Now load plugins and such
require "mappings"
diff --git a/lua/lsp_config.lua b/lua/lsp_config.lua
@@ -2,20 +2,17 @@ local lsp = require 'lspconfig'
vim.cmd [[packadd nvim-lspconfig]]
vim.diagnostic.config {
- virtual_text = {
- severity = {
- min = vim.diagnostic.severity.WARN
- }
- },
+ virtual_text = false,
severity_sort = true,
- signs = false
+ signs = false,
+ virtual_lines = true
}
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.hover, { border = 'rounded' })
local ignore_messages = {
- ltex = true
+ ltex = true,
}
local function progress_handle(infos)
@@ -38,27 +35,38 @@ vim.api.nvim_create_autocmd({ "User LspProgressUpdate" }, {
})
local function on_attach(client, bufnr)
- local function buf_set_keymap(lhs, rhs)
- vim.api.nvim_buf_set_keymap(bufnr, 'n', lhs, string.format("<cmd>lua %s<CR>", rhs),
- { noremap = true, silent = true })
+ local function buf_set_keymap(lhs, func)
+ vim.keymap.set("n", lhs, "", {
+ remap = false,
+ silent = true,
+ buffer = bufnr,
+ callback = func
+ })
+ end
+
+ local function set_autocmd(event, func)
+ vim.api.nvim_create_autocmd(event, {
+ buffer = bufnr,
+ callback = function() pcall(func) end
+ })
end
-- Mappings.
-- autocmd CursorHold,CursorHoldI *.rs lua vim.lsp.diagnostic.show_line_diagnostics{focusable=false}
-- See `:help vim.lsp.*` for documentation on any of the below functions
- buf_set_keymap('gD', 'vim.lsp.buf.implementation()')
- buf_set_keymap('<Leader>d', 'vim.lsp.buf.definition()')
- buf_set_keymap('K', 'vim.lsp.buf.hover()')
- buf_set_keymap('<C-S-K>', 'vim.lsp.buf.signature_help()')
- buf_set_keymap('gr', 'vim.lsp.buf.rename()')
- buf_set_keymap('<Leader>a', 'vim.lsp.buf.code_action()')
- buf_set_keymap('[d', 'vim.diagnostic.goto_prev()')
- buf_set_keymap(']d', 'vim.diagnostic.goto_next()')
- buf_set_keymap('<Leader>l', 'vim.diagnostic.setloclist()')
- buf_set_keymap('<Leader>q', 'vim.diagnostic.setqflist()')
- buf_set_keymap('<Leader>=', 'vim.lsp.buf.format { async = true }')
- buf_set_keymap('gR', 'require"telescope.builtin".lsp_references()')
- buf_set_keymap('<Leader>s', 'require"telescope.builtin".lsp_dynamic_workspace_symbols()')
+ buf_set_keymap('gD', vim.lsp.buf.implementation)
+ buf_set_keymap('<Leader>d', vim.lsp.buf.definition)
+ buf_set_keymap('K', vim.lsp.buf.hover)
+ buf_set_keymap('<C-S-K>', vim.lsp.buf.signature_help)
+ buf_set_keymap('gr', vim.lsp.buf.rename)
+ buf_set_keymap('<Leader>a', vim.lsp.buf.code_action)
+ buf_set_keymap('[d', vim.diagnostic.goto_prev)
+ buf_set_keymap(']d', vim.diagnostic.goto_next)
+ buf_set_keymap('<Leader>l', vim.diagnostic.setloclist)
+ buf_set_keymap('<Leader>q', vim.diagnostic.setqflist)
+ buf_set_keymap('<Leader>=', function() vim.lsp.buf.format { async = true } end)
+ buf_set_keymap('gR', require"telescope.builtin".lsp_references)
+ buf_set_keymap('<Leader>s', require"telescope.builtin".lsp_dynamic_workspace_symbols)
-- I always have telecope on, but we never know
local f = nil
@@ -69,16 +77,24 @@ local function on_attach(client, bufnr)
end
end
if pcall(require, 'telescope') and f then
- buf_set_keymap('<Leader>e', string.format('require"telescope.builtin".fd{ cwd = "%s" }', f))
+ buf_set_keymap('<Leader>e', function() require"telescope.builtin".fd{ cwd = f } end)
end
- vim.api.nvim_buf_call(bufnr, function()
- vim.api.nvim_command [[autocmd CursorHold <buffer> lua pcall(vim.diagnostic.open_float, 0, {focusable = false, scope = 'cursor'})]]
- if client.supports_method('textDocument/documentHighlight') then
- vim.api.nvim_command [[autocmd CursorHold <buffer> lua pcall(vim.lsp.buf.document_highlight)]]
- vim.api.nvim_command [[autocmd CursorMoved <buffer> lua pcall(vim.lsp.buf.clear_references)]]
- end
+ -- LSP lines setup
+ set_autocmd("InsertEnter", function()
+ vim.diagnostic.config { virtual_lines = false }
end)
+ set_autocmd("InsertLeave", function()
+ vim.diagnostic.config { virtual_lines = true }
+ end)
+
+ if client.supports_method('textDocument/documentHighlight') then
+ set_autocmd("CursorHold", vim.lsp.buf.document_highlight)
+ set_autocmd("CursorMoved", vim.lsp.buf.clear_references)
+ end
+ -- vim.api.nvim_buf_call(bufnr, function()
+ -- vim.api.nvim_command [[autocmd CursorHold <buffer> lua pcall(vim.diagnostic.open_float, 0, {focusable = false, scope = 'cursor'})]]
+ -- end)
end
-- TexLab and LTeX things
@@ -273,6 +289,9 @@ local lsps = {
executable = "zathura",
args = { "--synctex-forward", "%l:1:%f", "%p" }
},
+ latex = {
+ rootDirectory = ".",
+ },
}
},
},
@@ -286,6 +305,11 @@ require 'ltex-ls'.setup {
on_attach = on_attach,
capabilities = capabilities,
filetypes = { "latex", "tex", "bib", "markdown", "gitcommit", "text" },
+ use_spellfile = true,
+ handlers = {
+ ["ltex/workspaceSpecificConfiguration"] = vim.lsp.with(require 'ltex-ls.handlers'.workspace_configuration,
+ { debug = true })
+ },
settings = {
ltex = {
enabled = { "latex", "tex", "bib", "markdown", },
diff --git a/lua/neogit-config.lua b/lua/neogit-config.lua
@@ -5,6 +5,7 @@ gitsigns.setup {
current_line_blame_opts = {
delay = 1000,
},
+ sign_priority = 1000,
on_attach = function(bufnr)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-S>', ':Gitsigns stage_hunk<CR>', { silent = true })
vim.api.nvim_buf_set_keymap(bufnr, 'v', '<C-S>', ':Gitsigns stage_hunk<CR>', { silent = true })
diff --git a/lua/plugins.lua b/lua/plugins.lua
@@ -2,42 +2,43 @@
local execute = vim.api.nvim_command
local fn = vim.fn
-local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
+local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
local packer_bootstrap = false
if fn.empty(fn.glob(install_path)) > 0 then
- packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
+ packer_bootstrap = fn.system({ 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim',
+ install_path })
end
-local packer = require"packer"
+local packer = require "packer"
return packer.startup(function(use)
local function localuse(spec)
- local function path_trans(path)
- return '~/src/plugins/' .. string.gsub(path, ".+/", "")
- end
-
- if type(spec) == "string" then
- use(path_trans(spec))
- else
- local path = spec[1]
- spec[1] = path_trans(path)
- use(spec)
- end
+ local function path_trans(path)
+ return '~/src/plugins/' .. string.gsub(path, ".+/", "")
+ end
+
+ if type(spec) == "string" then
+ use(path_trans(spec))
+ else
+ local path = spec[1]
+ spec[1] = path_trans(path)
+ use(spec)
+ end
end
- use {'wbthomason/packer.nvim'}
+ use { 'wbthomason/packer.nvim' }
-- Basic
use {
- 'nvim-telescope/telescope.nvim',
- requires = {
- 'nvim-lua/popup.nvim',
- 'nvim-lua/plenary.nvim',
- 'nvim-telescope/telescope-fzy-native.nvim'
- },
- config = function()
- require'tele_config'
- end
+ 'nvim-telescope/telescope.nvim',
+ requires = {
+ 'nvim-lua/popup.nvim',
+ 'nvim-lua/plenary.nvim',
+ 'nvim-telescope/telescope-fzy-native.nvim'
+ },
+ config = function()
+ require 'tele_config'
+ end
}
-- use { 'neovim/nvimdev.nvim', requires = {'neomake/neomake'}}
@@ -47,8 +48,14 @@ return packer.startup(function(use)
use 'tpope/vim-surround'
-- LSP related
- use {'neovim/nvim-lspconfig', requires = "williamboman/nvim-lsp-installer"}
- localuse { 'vigoux/ltex-ls.nvim', requires = 'neovim/nvim-lspconfig'}
+ use {
+ "https://git.sr.ht/~whynothugo/lsp_lines.nvim",
+ config = function()
+ require("lsp_lines").setup()
+ end,
+ }
+ use { 'neovim/nvim-lspconfig', requires = "williamboman/nvim-lsp-installer" }
+ localuse { 'vigoux/ltex-ls.nvim', requires = 'neovim/nvim-lspconfig' }
-- Treesitter related
localuse 'nvim-treesitter/nvim-treesitter'
@@ -61,13 +68,14 @@ return packer.startup(function(use)
-- Misc
localuse 'vim-conf-live/pres.vim'
localuse 'vigoux/architext.nvim'
- localuse {'vigoux/complementree.nvim', requires = {'L3MON4D3/LuaSnip', 'nvim-treesitter/nvim-treesitter', {'romgrk/fzy-lua-native', run = 'make'}} }
+ localuse { 'vigoux/complementree.nvim',
+ requires = { 'L3MON4D3/LuaSnip', 'nvim-treesitter/nvim-treesitter', { 'romgrk/fzy-lua-native', run = 'make' } } }
localuse { 'vigoux/ratatoskr.nvim', opt = true }
use 'L3MON4D3/LuaSnip'
use 'bfredl/luarefvim' -- lua docs from nvim
- use { 'norcalli/nvim-colorizer.lua', config = function ()
- require'colorizer'.setup()
- end}
+ use { 'norcalli/nvim-colorizer.lua', config = function()
+ require 'colorizer'.setup()
+ end }
use 'lewis6991/impatient.nvim'
-- Git because git
@@ -85,6 +93,7 @@ return packer.startup(function(use)
-- filetypes
use 'rhysd/vim-llvm'
use 'tamarin-prover/editors'
+ localuse 'vigoux/infer.nvim'
if packer_bootstrap then
packer.sync()
diff --git a/lua/ts_config.lua b/lua/ts_config.lua
@@ -1,15 +1,3 @@
-local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
-if not parser_config.vim then
- parser_config.vim = {
- install_info = {
- url = "https://github.com/vigoux/tree-sitter-viml",
- files = {"src/parser.c", "src/scanner.c"}
- },
- filetype = "vim",
- maintainers = { "@vigoux" },
- }
-end
-
require'nvim-treesitter.configs'.setup {
highlight = {
enable = true, -- false will disable the whole extension