nvim: bindings and indent!

This commit is contained in:
Daniel Lundin 2021-04-20 18:10:56 +02:00
parent 301dab336e
commit 781a076b6d
5 changed files with 116 additions and 101 deletions

View file

@ -12,6 +12,7 @@ augroup recompile_plugins
autocmd BufWritePost plugins.lua call <SID>recompile_plugins()
augroup END
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
"" Temporary hacks

View file

@ -3,111 +3,119 @@ local lspconfig = require("lspconfig")
local util = require("lspconfig.util")
vim.lsp.handlers["textDocument/publishDiagnostics"] =
vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics,
{
update_in_insert = false,
virtual_text = {prefix = "‹❮❰ " }
}
vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics,
{
update_in_insert = false,
virtual_text = {prefix = "‹❮❰ " }
}
)
vim.fn.sign_define(
"LspDiagnosticsSignError",
{
text = "🔥",
texthl = "LspDiagnosticsSignError"
}
"LspDiagnosticsSignError",
{
text = "🔥",
texthl = "LspDiagnosticsSignError"
}
)
vim.fn.sign_define(
"LspDiagnosticsSignWarning",
{
text = "",
texthl = "LspDiagnosticsSignWarning"
}
"LspDiagnosticsSignWarning",
{
text = "",
texthl = "LspDiagnosticsSignWarning"
}
)
vim.fn.sign_define(
"LspDiagnosticsSignInformation",
{
text = "💡",
texthl = "LspDiagnosticsSignInformation",
}
"LspDiagnosticsSignInformation",
{
text = "💡",
texthl = "LspDiagnosticsSignInformation",
}
)
vim.fn.sign_define(
"LspDiagnosticsSignHint",
{
text = "💡",
texthl = "LspDiagnosticsSignHint",
}
"LspDiagnosticsSignHint",
{
text = "💡",
texthl = "LspDiagnosticsSignHint",
}
)
local on_attach = function()
require("folding").on_attach()
require("folding").on_attach()
end
-- simple setups --
local servers = {
"bashls",
"cssls",
"dockerls",
"gopls",
"html",
"jsonls",
-- "sql",
"sumneko_lua",
"terraformls",
"bashls",
"cssls",
"dockerls",
"gopls",
"html",
"jsonls",
-- "sql",
"sumneko_lua",
"terraformls",
"yamlls",
}
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {on_attach = on_attach}
lspconfig[lsp].setup {on_attach = on_attach}
end
local efm_prettier = {
formatCommand = "prettier --stdin-filepath ${INPUT}",
formatStdin = true
formatCommand = "prettier --stdin-filepath ${INPUT}",
formatStdin = true
}
lspconfig.sumneko_lua.setup {
cmd = {"lua-language-server", "-E", "/usr/share/lua-language-server/main.lua"},
settings = {
Lua = {
completion = {kewordSnippet = "Disable"},
diagnostics = {
enable = true,
globals = {"renoise", "use", "vim"}
},
runtime = {
version = "LuaJIT",
path = {"?.lua", "?/init.lua", "?/?.lua"}
},
workspace = {
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true,
[vim.fn.stdpath("config") .. "/lua"] = true,
[vim.fn.stdpath("data") .. "/site/pack"] = true
},
maxPreload = 2000,
preloadFileSize = 1000
}
}
}
cmd = {"lua-language-server", "-E", "/usr/share/lua-language-server/main.lua"},
settings = {
Lua = {
completion = {kewordSnippet = "Disable"},
diagnostics = {
enable = true,
globals = {"renoise", "use", "vim"}
},
runtime = {
version = "LuaJIT",
path = {"?.lua", "?/init.lua", "?/?.lua"}
},
workspace = {
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true,
[vim.fn.stdpath("config") .. "/lua"] = true,
[vim.fn.stdpath("data") .. "/site/pack"] = true
},
maxPreload = 2000,
preloadFileSize = 1000
}
}
}
}
local yaml_is_k8s = function(bufnr)
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, 50, false) -- Stop after the first 50 lines
for _, l in pairs(lines) do
if string.find(l, "apiVersion") ~= nil then return true end
end
return false
end
lspconfig.yamlls.setup {
on_attach = on_attach,
settings = {
yaml = {
format = {enable = true, singleQuote = true},
schemaStore = {enable = true},
schemas = {
["https://json.schemastore.org/github-workflow"] = "*.github/workflows/*",
["https://json.schemastore.org/kustomization.json"] = "kustomization.yaml",
["https://json.schemastore.org/ansible-role-2.9.json"] = "*/tasks/*.y*ml",
["kubernetes" ] = "*.yaml",
},
validate = true
}
}
settings = {
yaml = {
format = {enable = true, singleQuote = true},
schemaStore = {enable = true},
schemas = {
-- ["https://json.schemastore.org/github-workflow"] = "*.github/workflows/*",
["https://json.schemastore.org/kustomization.json"] = "kustomization.yaml",
-- ["https://json.schemastore.org/ansible-role-2.9.json"] = "*/tasks/*.y*ml",
-- kubernetes = "*.yaml",
},
validate = true
}
}
}

View file

@ -3,8 +3,11 @@ require("nvim-treesitter.configs").setup {
highlight = {
enable = true,
use_languagetree = true,
},
},
indent = {
enable = false
},
playground = {
enable = true,

View file

@ -1,6 +1,6 @@
vim.bo.undofile = true
vim.cmd('set completeopt-=preview')
vim.cmd('set viewoptions-=options')
vim.cmd[[set undofile]]
vim.cmd[[set completeopt-=preview]]
vim.cmd[[set viewoptions-=options]]
vim.g.mapleader = ','
vim.o.clipboard = 'unnamed'
vim.o.hidden = true
@ -13,7 +13,10 @@ vim.o.updatetime = 100
vim.o.autochdir = true
vim.o.backupdir = "/home/dln/.local/share/nvim/backup//"
--- Indent
vim.bo.autoindent = true
vim.o.breakindent = true
vim.bo.expandtab = true
vim.bo.smartindent = true
vim.o.joinspaces = false
@ -21,9 +24,9 @@ vim.o.listchars = 'extends:,precedes:,nbsp:·,tab:→ ,trail:·'
vim.wo.foldlevel = 99
vim.wo.linebreak = true
vim.wo.list = true
vim.o.shiftwidth = 2
vim.o.tabstop = 2
vim.o.softtabstop = 2
vim.o.shiftwidth = 4
vim.o.tabstop = 4
vim.o.softtabstop = 4
--- Search
vim.cmd('set path+=**')
@ -33,7 +36,7 @@ vim.o.smartcase = true
vim.o.wildmode = 'longest:full,full'
if vim.fn.executable('rg') then
vim.o.grepprg = 'rg --vimgrep --no-heading --smart-case'
vim.o.grepprg = 'rg --vimgrep --no-heading --smart-case'
end
--- Completion
@ -48,6 +51,7 @@ vim.o.sidescrolloff = 5
vim.o.termguicolors = true
vim.wo.cursorline = true
vim.wo.number = true
vim.wo.signcolumn = "yes"
vim.o.laststatus = 0
--- Key mappings
@ -63,23 +67,22 @@ vim.g.netrw_dirhistmax = 0
require('plugins')
-- local border = { '╭', '─' ,'╮', '│', '╯', '─', '╰', '│' }
local border = { '🭽', '' ,'🭾', '', '🭿', '', '🭼', '' }
vim.lsp.handlers["textDocument/hover"] =
vim.lsp.with(
vim.lsp.handlers.hover,
{
border = border
}
vim.lsp.with(
vim.lsp.handlers.hover,
{
border = border
}
)
vim.lsp.handlers["textDocument/signatureHelp"] =
vim.lsp.with(
vim.lsp.handlers.signature_help,
{
border = border
}
vim.lsp.with(
vim.lsp.handlers.signature_help,
{
border = border
}
)
-- vim.cmd [[nnoremap <buffer><silent> <C-space> :lua vim.lsp.diagnostic.show_line_diagnostics({ border = border })<CR>]]

View file

@ -42,7 +42,7 @@ return require('packer').startup(function()
end
end
utils.mapx("is", "<C-space>", "v:lua.complete('<C-n>', '<Tab>')")
utils.mapx("is", "<C-Space>", "v:lua.complete('<C-n>', '<Tab>')")
utils.mapx("is", "<Tab>", "v:lua.complete('<C-n>', '<Tab>')")
utils.mapx("is", "<S-Tab>", "v:lua.complete('<C-p>', '<C-h>')")
utils.mapx("x", "<CR>", "compe:#confirm('<CR')")
@ -83,7 +83,7 @@ return require('packer').startup(function()
-- vim.g.indent_blankline_show_end_of_line = true
vim.g.indent_blankline_show_first_indent_level = true
vim.g.indent_blankline_show_trailing_blankline_indent = true
vim.g.indent_blankline_char_highlight_list = { 'Indent1', 'Indent2', 'Indent3', 'Indent4'}
vim.g.indent_blankline_char_highlight_list = { 'Indent1', 'Indent2', 'Indent3', 'Indent4', 'Indent5', 'Indent6'}
end
}
@ -99,9 +99,9 @@ return require('packer').startup(function()
map('n', 'rn', '<Cmd>lua vim.lsp.buf.rename()<CR>')
map('n', '[d', '<Cmd>lua vim.lsp.diagnostic.goto_prev()<CR>')
map('n', ']d', '<Cmd>lua vim.lsp.diagnostic.goto_next()<CR>')
map('n', 'wa', '<Cmd>lua vim.lsp.buf.add_workspace_folder()<CR>')
map('n', 'wr', '<Cmd>lua vim.lsp.buf.add_workspace_folder()<CR>')
map('n', 'wl', '<Cmd>lua vim.lsp.buf.add_workspace_folder()<CR>')
map('n', 'gwa', '<Cmd>lua vim.lsp.buf.add_workspace_folder()<CR>')
map('n', 'gwr', '<Cmd>lua vim.lsp.buf.add_workspace_folder()<CR>')
map('n', 'gwl', '<Cmd>lua vim.lsp.buf.add_workspace_folder()<CR>')
end
}