Updates for 0.11
This commit is contained in:
parent
46b767e26f
commit
031b6403df
9 changed files with 77 additions and 166 deletions
|
@ -1,5 +0,0 @@
|
|||
# NVIM Configuration
|
||||
|
||||
## Lua
|
||||
|
||||
<https://github.com/LuaLS/lua-language-server/releases/>
|
|
@ -1 +0,0 @@
|
|||
syn keyword cOperator assert
|
15
build.sh
15
build.sh
|
@ -1,15 +0,0 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
(
|
||||
cd opt/lua-language-server
|
||||
git submodule update --init --recursive
|
||||
|
||||
(
|
||||
cd 3rd/luamake
|
||||
./compile/build.sh
|
||||
)
|
||||
|
||||
3rd/luamake/luamake rebuild
|
||||
)
|
||||
|
||||
# EOF
|
3
init.vim
3
init.vim
|
@ -19,9 +19,10 @@ set ts=2
|
|||
set et
|
||||
|
||||
set smartcase
|
||||
"set smarttab
|
||||
set nohlsearch
|
||||
|
||||
let g:c_syntax_for_h = 1
|
||||
|
||||
autocmd FileType c,cpp set cindent
|
||||
autocmd FileType c,cpp set cinoptions=:0,l0,t0,g0,(0
|
||||
|
||||
|
|
|
@ -10,150 +10,59 @@ require("config.lsp.vls")
|
|||
require("config.lsp.rust_analyzer")
|
||||
|
||||
local api = vim.api
|
||||
local opts = { noremap = true, silent = true }
|
||||
local keymap = vim.keymap.set
|
||||
|
||||
local function keymappings(_, bufnr)
|
||||
local opts = { noremap = true, silent = true }
|
||||
keymap("n", "[d", "<cmd>lua vim.diagnostic.jump({count = -1, float = true})<CR>", opts)
|
||||
keymap("n", "]d", "<cmd>lua vim.diagnostic.jump({count = 1, float = true})<CR>", opts)
|
||||
keymap("n", "[e", "<cmd>lua vim.diagnostic.jump({count = -1, severity = vim.diagnostic.severity.ERROR, float = true})<CR>", opts)
|
||||
keymap("n", "]e", "<cmd>lua vim.diagnostic.jump({count = -1, severity = vim.diagnostic.severity.ERROR, float = true})<CR>", opts)
|
||||
|
||||
keymap("n", "K", vim.lsp.buf.hover, { buffer = bufnr })
|
||||
keymap("n", "[d", "<cmd>lua vim.diagnostic.goto_prev()<CR>", opts)
|
||||
keymap("n", "]d", "<cmd>lua vim.diagnostic.goto_next()<CR>", opts)
|
||||
keymap("n", "[e", "<cmd>lua vim.diagnostic.goto_prev({severity = vim.diagnostic.severity.ERROR})<CR>", opts)
|
||||
keymap("n", "]e", "<cmd>lua vim.diagnostic.goto_next({severity = vim.diagnostic.severity.ERROR})<CR>", opts)
|
||||
keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||
keymap("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
||||
keymap("n", "gh", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
||||
keymap("n", "gI", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
||||
keymap("n", "gt", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
||||
|
||||
keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||
keymap("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
||||
keymap("n", "gh", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
||||
keymap("n", "gI", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
||||
keymap("n", "gb", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
||||
keymap("n", "ca", "<cmd>lua require('fzf-lua').lsp_code_actions()<CR>", opts)
|
||||
|
||||
keymap("n", "ca", "<cmd>lua require('fzf-lua').lsp_code_actions()<CR>", opts)
|
||||
keymap("n", "gl", "<cmd>lua vim.diagnostic.reset()<CR>", opts)
|
||||
|
||||
keymap("n", "gl", "<cmd>lua vim.diagnostic.reset()<CR>", opts)
|
||||
-- Automatic completion triggering
|
||||
-- vim.api.nvim_create_autocmd('LspAttach', {
|
||||
-- callback = function(ev)
|
||||
-- local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
-- if client:supports_method('textDocument/completion') then
|
||||
-- vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true })
|
||||
-- end
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
-- api.nvim_set_keymap("i", "<Tab>", [[pumvisible() ? "\<C-n>" : "\<Tab>"]], { noremap = true, expr = true })
|
||||
-- api.nvim_set_keymap("i", "<S-Tab>", [[pumvisible() ? "\<C-p>" : "\<S-Tab>"]], { noremap = true, expr = true })
|
||||
end
|
||||
|
||||
local function highlighting(client, bufnr)
|
||||
if client.server_capabilities.documentHighlightProvider then
|
||||
local lsp_highlight_grp = api.nvim_create_augroup("LspDocumentHighlight", { clear = true })
|
||||
api.nvim_create_autocmd("CursorHold", {
|
||||
callback = function()
|
||||
vim.schedule(vim.lsp.buf.document_highlight)
|
||||
end,
|
||||
group = lsp_highlight_grp,
|
||||
buffer = bufnr,
|
||||
})
|
||||
api.nvim_create_autocmd("CursorMoved", {
|
||||
callback = function()
|
||||
vim.schedule(vim.lsp.buf.clear_references)
|
||||
end,
|
||||
group = lsp_highlight_grp,
|
||||
buffer = bufnr,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
local function lsp_handlers()
|
||||
local diagnostics = {
|
||||
Error = "E:",
|
||||
Warning = "W:",
|
||||
Hint = "",
|
||||
Information = "I:",
|
||||
Question = "Q:",
|
||||
}
|
||||
local signs = {
|
||||
{ name = "DiagnosticSignError", text = diagnostics.Error },
|
||||
{ name = "DiagnosticSignWarn", text = diagnostics.Warning },
|
||||
{ name = "DiagnosticSignHint", text = diagnostics.Hint },
|
||||
{ name = "DiagnosticSignInfo", text = diagnostics.Info },
|
||||
}
|
||||
for _, sign in ipairs(signs) do
|
||||
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = sign.name })
|
||||
end
|
||||
|
||||
-- LSP handlers configuration
|
||||
local config = {
|
||||
float = {
|
||||
focusable = true,
|
||||
style = "minimal",
|
||||
border = "rounded",
|
||||
},
|
||||
|
||||
diagnostic = {
|
||||
virtual_text = false,
|
||||
signs = {
|
||||
active = signs,
|
||||
},
|
||||
underline = true,
|
||||
update_in_insert = false,
|
||||
severity_sort = true,
|
||||
float = {
|
||||
focusable = true,
|
||||
style = "minimal",
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
header = "",
|
||||
prefix = "",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
vim.diagnostic.config(config.diagnostic)
|
||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, config.float)
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, config.float)
|
||||
end
|
||||
|
||||
local function formatting(client, bufnr)
|
||||
if client.server_capabilities.documentFormattingProvider then
|
||||
local function format()
|
||||
local view = vim.fn.winsaveview()
|
||||
vim.lsp.buf.format({
|
||||
async = true,
|
||||
filter = function(attached_client)
|
||||
return attached_client.name ~= ""
|
||||
end,
|
||||
})
|
||||
vim.fn.winrestview(view)
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
callback = function(ev)
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if client:supports_method('textDocument/completion') then
|
||||
vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = false })
|
||||
end
|
||||
|
||||
local lsp_format_grp = api.nvim_create_augroup("LspFormat", { clear = true })
|
||||
api.nvim_create_autocmd("BufWritePre", {
|
||||
callback = function()
|
||||
vim.schedule(format)
|
||||
end,
|
||||
group = lsp_format_grp,
|
||||
buffer = bufnr,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
local function on_attach(client, bufnr)
|
||||
if client.server_capabilities.completionProvider then
|
||||
vim.bo[bufnr].omnifunc = "v:lua.vim.lsp.omnifunc"
|
||||
vim.bo[bufnr].completefunc = "v:lua.vim.lsp.omnifunc"
|
||||
end
|
||||
|
||||
if client.server_capabilities.definitionProvider then
|
||||
vim.bo[bufnr].tagfunc = "v:lua.vim.lsp.tagfunc"
|
||||
end
|
||||
|
||||
if client.server_capabilities.documentFormattingProvider then
|
||||
vim.bo[bufnr].formatexpr = "v:lua.vim.lsp.formatexpr()"
|
||||
end
|
||||
|
||||
keymappings(client, bufnr)
|
||||
--highlighting(client, bufnr)
|
||||
--formatting(client, bufnr)
|
||||
end
|
||||
|
||||
lsp_handlers()
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
local bufnr = args.buf
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
on_attach(client, bufnr)
|
||||
end,
|
||||
})
|
||||
|
||||
-- Old on-attach
|
||||
-- vim.api.nvim_create_autocmd('LspAttach', {
|
||||
-- callback = function(ev)
|
||||
-- local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
--
|
||||
-- if client.server_capabilities.completionProvider then
|
||||
-- vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
|
||||
-- vim.bo[ev.buf].completefunc = "v:lua.vim.lsp.omnifunc"
|
||||
-- end
|
||||
--
|
||||
-- if client.server_capabilities.definitionProvider then
|
||||
-- vim.bo[ev.buf].tagfunc = "v:lua.vim.lsp.tagfunc"
|
||||
-- end
|
||||
--
|
||||
-- if client.server_capabilities.documentFormattingProvider then
|
||||
-- vim.bo[ev.buf].formatexpr = "v:lua.vim.lsp.formatexpr()"
|
||||
-- end
|
||||
-- end,
|
||||
-- })
|
||||
|
|
17
lua/init.lua
17
lua/init.lua
|
@ -5,6 +5,23 @@ vim.api.nvim_create_autocmd({ "VimLeave" }, {
|
|||
end,
|
||||
})
|
||||
|
||||
vim.diagnostic.config({
|
||||
-- Use the default configuration
|
||||
-- virtual_lines = true,
|
||||
|
||||
-- Alternatively, customize specific options
|
||||
-- virtual_lines = {
|
||||
-- -- Only show virtual line diagnostics for the current cursor line
|
||||
-- current_line = true,
|
||||
-- },
|
||||
|
||||
-- Open in floating window
|
||||
float = {
|
||||
source = 'always',
|
||||
border = 'shadow',
|
||||
},
|
||||
})
|
||||
|
||||
require("nvim-web-devicons").setup {}
|
||||
|
||||
require("fidget").setup {
|
||||
|
|
17
nvim.vim
17
nvim.vim
|
@ -1,6 +1,13 @@
|
|||
execute pathogen#infect()
|
||||
|
||||
colorscheme vim
|
||||
colorscheme wildcharm
|
||||
highlight SignColumn guibg=#222222
|
||||
|
||||
set winblend=0
|
||||
|
||||
if has('nvim-0.11')
|
||||
set winborder=solid
|
||||
end
|
||||
|
||||
highlight ExtraWhitespace ctermbg=darkgreen guibg=darkgreen
|
||||
match ExtraWhitespace /\s\+$\| \+\ze\t/
|
||||
|
@ -20,10 +27,10 @@ autocmd BufNewFile *.adoc 0r ~/.vim/template/adoc
|
|||
|
||||
autocmd BufNewFile,BufRead *.pio setfiletype pioasm
|
||||
|
||||
highlight Pmenu ctermbg=235 guibg=black
|
||||
highlight Pmenu ctermfg=white guifg=white
|
||||
highlight PmenuSel ctermbg=235 guibg=black
|
||||
highlight PmenuSel ctermfg=yellow guifg=yellow
|
||||
"highlight Pmenu ctermbg=235 guibg=black
|
||||
"highlight Pmenu ctermfg=white guifg=white
|
||||
"highlight PmenuSel ctermbg=235 guibg=black
|
||||
"highlight PmenuSel ctermfg=yellow guifg=yellow
|
||||
|
||||
" For Pandoc
|
||||
let g:pandoc#spell#enabled=0
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../lua-language-server/bin/lua-language-server
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 2dfb12ad3759acb7ff47b4c5c54ad0a62c598b22
|
Loading…
Reference in a new issue