nvim: all 0.5 and lua, baby!
This commit is contained in:
parent
5023b64b04
commit
6fddacc265
16 changed files with 623 additions and 1655 deletions
113
.config/nvim/lua/dln/lsp-config.lua
Normal file
113
.config/nvim/lua/dln/lsp-config.lua
Normal file
|
@ -0,0 +1,113 @@
|
|||
local lspconfig = require("lspconfig")
|
||||
-- local configs = require("lspconfig.configs")
|
||||
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.fn.sign_define(
|
||||
"LspDiagnosticsSignError",
|
||||
{
|
||||
text = "🛑",
|
||||
texthl = "LspDiagnosticsSignError"
|
||||
}
|
||||
)
|
||||
|
||||
vim.fn.sign_define(
|
||||
"LspDiagnosticsSignWarning",
|
||||
{
|
||||
text = "⚠",
|
||||
texthl = "LspDiagnosticsSignWarning"
|
||||
}
|
||||
)
|
||||
vim.fn.sign_define(
|
||||
"LspDiagnosticsSignInformation",
|
||||
{
|
||||
text = "💡",
|
||||
texthl = "LspDiagnosticsSignInformation"
|
||||
}
|
||||
)
|
||||
vim.fn.sign_define(
|
||||
"LspDiagnosticsSignHint",
|
||||
{
|
||||
text = "💡",
|
||||
texthl = "LspDiagnosticsSignHint"
|
||||
}
|
||||
)
|
||||
|
||||
local on_attach = function()
|
||||
require("folding").on_attach()
|
||||
end
|
||||
|
||||
-- simple setups --
|
||||
local servers = {
|
||||
"bashls",
|
||||
"cssls",
|
||||
"dockerls",
|
||||
"gopls",
|
||||
"html",
|
||||
"jsonls",
|
||||
-- "sql",
|
||||
"sumneko_lua",
|
||||
"terraformls",
|
||||
"yamlls",
|
||||
}
|
||||
|
||||
for _, lsp in ipairs(servers) do
|
||||
lspconfig[lsp].setup {on_attach = on_attach}
|
||||
end
|
||||
|
||||
local efm_prettier = {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
8
.config/nvim/lua/dln/lspsaga.lua
Normal file
8
.config/nvim/lua/dln/lspsaga.lua
Normal file
|
@ -0,0 +1,8 @@
|
|||
require("lspsaga").init_lsp_saga {
|
||||
use_saga_diagnostic_sign = false,
|
||||
-- error_sign = "",
|
||||
-- warn_sign = "",
|
||||
-- infor_sign = "",
|
||||
-- hint_sign = "➤",
|
||||
code_action_prompt = {enable = false}
|
||||
}
|
60
.config/nvim/lua/dln/telescope.lua
Normal file
60
.config/nvim/lua/dln/telescope.lua
Normal file
|
@ -0,0 +1,60 @@
|
|||
local telescope = require("telescope")
|
||||
local actions = require("telescope.actions")
|
||||
local previewers = require("telescope.previewers")
|
||||
|
||||
-- Setup
|
||||
telescope.setup {
|
||||
defaults = {
|
||||
layout_strategy = "flex",
|
||||
-- layout_defaults = {flip_columns = 160},
|
||||
preview_cutoff = 10,
|
||||
results_height = 1,
|
||||
mappings = {
|
||||
i = {
|
||||
["<CR>"] = actions.select_default + actions.center,
|
||||
["<esc>"] = actions.close,
|
||||
["<tab>"] = actions.add_selection
|
||||
}
|
||||
},
|
||||
color_devicons = true,
|
||||
file_previewer = previewers.vim_buffer_cat.new,
|
||||
grep_previewer = previewers.vim_buffer_vimgrep.new,
|
||||
qflist_previewer = previewers.vim_buffer_qflist.new
|
||||
}
|
||||
}
|
||||
|
||||
-- TODO: Reduce preview ratio
|
||||
-- Override flex layout
|
||||
local layout_strategies = require("telescope.pickers.layout_strategies")
|
||||
local config = require("telescope.config")
|
||||
|
||||
layout_strategies.flex = function(self, max_columns, max_lines)
|
||||
local layout_config = self.layout_config or {}
|
||||
|
||||
local flip_columns = layout_config.flip_columns or 160 -- Here's why.
|
||||
local flip_lines = layout_config.flip_lines or 20
|
||||
|
||||
if max_columns < flip_columns and max_lines > flip_lines then
|
||||
self.layout_config = (config.values.layout_defaults or {})["vertical"]
|
||||
return layout_strategies.vertical(self, max_columns, max_lines)
|
||||
else
|
||||
self.layout_config = (config.values.layout_defaults or {})["horizontal"]
|
||||
return layout_strategies.horizontal(self, max_columns, max_lines)
|
||||
end
|
||||
end
|
||||
|
||||
-- Extensions
|
||||
telescope.load_extension("fzy_native")
|
||||
telescope.load_extension("gh")
|
||||
-- telescope.load_extension("packer") -- currently breaking packer
|
||||
|
||||
local M = {}
|
||||
|
||||
-- Pickers
|
||||
M.project_files = function()
|
||||
require("telescope.builtin").find_files {
|
||||
cwd = require("lspconfig.util").root_pattern(".git")(vim.fn.expand("%:p"))
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
56
.config/nvim/lua/dln/treesitter.lua
Normal file
56
.config/nvim/lua/dln/treesitter.lua
Normal file
|
@ -0,0 +1,56 @@
|
|||
require("nvim-treesitter.configs").setup {
|
||||
ensure_installed = "maintained",
|
||||
highlight = {enable = true},
|
||||
textobjects = {
|
||||
move = {
|
||||
enable = true,
|
||||
goto_next_start = {
|
||||
["]m"] = "@function.outer",
|
||||
["]]"] = "@class.outer"
|
||||
},
|
||||
goto_next_end = {
|
||||
["]M"] = "@function.outer",
|
||||
["]["] = "@class.outer"
|
||||
},
|
||||
goto_previous_start = {
|
||||
["[m"] = "@function.outer",
|
||||
["[["] = "@class.outer"
|
||||
},
|
||||
goto_previous_end = {
|
||||
["[M"] = "@function.outer",
|
||||
["[]"] = "@class.outer"
|
||||
}
|
||||
},
|
||||
select = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
-- You can use the capture groups defined in textobjects.scm
|
||||
["af"] = "@function.outer",
|
||||
["if"] = "@function.inner",
|
||||
["ac"] = "@class.outer",
|
||||
["ic"] = "@class.inner",
|
||||
-- Or you can define your own textobjects like this
|
||||
["iF"] = {
|
||||
python = "(function_definition) @function",
|
||||
cpp = "(function_definition) @function",
|
||||
c = "(function_definition) @function",
|
||||
java = "(method_declaration) @function"
|
||||
}
|
||||
}
|
||||
},
|
||||
swap = {
|
||||
enable = true,
|
||||
swap_next = {
|
||||
["<leader>l"] = "@parameter.inner"
|
||||
},
|
||||
swap_previous = {
|
||||
["<leader>h"] = "@parameter.inner"
|
||||
}
|
||||
}
|
||||
},
|
||||
--- nvim-ts-autotag ---
|
||||
autotag = {
|
||||
enable = true,
|
||||
filetypes = {"html", "javascriptreact", "xml"}
|
||||
}
|
||||
}
|
19
.config/nvim/lua/dln/utils.lua
Normal file
19
.config/nvim/lua/dln/utils.lua
Normal file
|
@ -0,0 +1,19 @@
|
|||
local M = {}
|
||||
|
||||
function M.term_codes(s)
|
||||
return vim.api.nvim_replace_termcodes(s, true, true, true)
|
||||
end
|
||||
|
||||
function M.map(mode, lhs, rhs, opts)
|
||||
opts = vim.tbl_extend("force", {noremap = true}, opts or {})
|
||||
for i = 1, #mode do
|
||||
vim.api.nvim_set_keymap(mode:sub(i, i), lhs, rhs, opts)
|
||||
end
|
||||
end
|
||||
|
||||
function M.mapx(mode, lhs, rhs, opts)
|
||||
opts = vim.tbl_extend("force", {expr = true, silent = true}, opts or {})
|
||||
return M.map(mode, lhs, rhs, opts)
|
||||
end
|
||||
|
||||
return M
|
62
.config/nvim/lua/init.lua
Normal file
62
.config/nvim/lua/init.lua
Normal file
|
@ -0,0 +1,62 @@
|
|||
vim.bo.undofile = true
|
||||
vim.cmd('set completeopt-=preview')
|
||||
vim.cmd('set viewoptions-=options')
|
||||
vim.g.mapleader = ','
|
||||
vim.o.clipboard = 'unnamed'
|
||||
vim.o.hidden = true
|
||||
vim.o.mouse = 'a'
|
||||
vim.o.splitbelow = true
|
||||
vim.o.splitright = true
|
||||
vim.o.ttimeout = true
|
||||
vim.o.ttimeoutlen = 50
|
||||
vim.o.updatetime = 100
|
||||
vim.o.autochdir = true
|
||||
vim.o.backupdir = "/home/dln/.local/share/nvim/backup//"
|
||||
|
||||
--- Indent
|
||||
vim.bo.expandtab = true
|
||||
vim.bo.smartindent = true
|
||||
vim.o.joinspaces = false
|
||||
vim.o.listchars = 'extends:›,precedes:‹,nbsp:·,tab:→ ,trail:·'
|
||||
vim.wo.foldlevel = 99
|
||||
vim.wo.linebreak = true
|
||||
vim.wo.list = true
|
||||
vim.o.shiftwidth = 4
|
||||
vim.o.tabstop = 4
|
||||
vim.o.softtabstop = 4
|
||||
|
||||
--- Search
|
||||
vim.cmd('set path+=**')
|
||||
vim.cmd('set wildignore+=*/tmp/*,/var/*,*.so,*.swp,*.zip,*.tar,*.pyc')
|
||||
vim.o.ignorecase = true
|
||||
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'
|
||||
end
|
||||
|
||||
--- Completion
|
||||
vim.cmd('set shortmess+=c')
|
||||
vim.o.completeopt = 'menuone,noinsert,noselect'
|
||||
|
||||
--- Appearance
|
||||
vim.o.background = 'light'
|
||||
vim.o.scrolloff = 8
|
||||
vim.o.showmode = false
|
||||
vim.o.sidescrolloff = 5
|
||||
vim.o.termguicolors = true
|
||||
vim.wo.cursorline = true
|
||||
vim.wo.number = true
|
||||
|
||||
--- Key mappings
|
||||
local map = require("dln.utils").map
|
||||
map('n', '<C-l>', ':let @/=""<CR>') -- clear search
|
||||
map('n', 'H', '^')
|
||||
map('n', 'L', '$')
|
||||
map('i', '', '<C-w>')
|
||||
|
||||
--- Plugins
|
||||
vim.g.netrw_dirhistmax = 0
|
||||
|
||||
require('plugins')
|
147
.config/nvim/lua/plugins.lua
Normal file
147
.config/nvim/lua/plugins.lua
Normal file
|
@ -0,0 +1,147 @@
|
|||
return require('packer').startup(function()
|
||||
use "pierreglaser/folding-nvim"
|
||||
use 'tjdevries/colorbuddy.vim'
|
||||
use 'wbthomason/packer.nvim'
|
||||
|
||||
use {
|
||||
'b3nj5m1n/kommentary',
|
||||
config = function()
|
||||
require('kommentary.config').use_extended_mappings()
|
||||
vim.api.nvim_set_keymap("n", "", "<Plug>kommentary_line_default", {}) -- C-/
|
||||
vim.api.nvim_set_keymap("v", "", "<Plug>kommentary_visual_default", {}) -- C-/
|
||||
end
|
||||
}
|
||||
|
||||
use {
|
||||
"glepnir/lspsaga.nvim",
|
||||
config = function()
|
||||
require("dln.lspsaga")
|
||||
|
||||
local map = require("dln.utils").map
|
||||
local o = {silent = true}
|
||||
map("n", "gh", ":Lspsaga lsp_finder<CR>", o)
|
||||
map("n", "<leader>ca", ":Lspsaga code_action<CR>", o)
|
||||
-- map("n", "<leader>k", ":Lspsaga hover_doc<CR>", o)
|
||||
map("n", "gs", ":Lspsaga signature_help<CR>", o)
|
||||
map("n", "gr", ":Lspsaga rename<CR>", o)
|
||||
map("n", "gd", ":Lspsaga preview_definition<CR>", o)
|
||||
map("n", "<leader>cd", ":Lspsaga show_line_diagnostics<CR>", o)
|
||||
map("n", "[d", ":Lspsaga diagnostic_jump_prev<CR>", o)
|
||||
map("n", "]d", ":Lspsaga diagnostic_jump_next<CR>", o)
|
||||
end
|
||||
}
|
||||
|
||||
use {
|
||||
"hrsh7th/nvim-compe",
|
||||
config = function()
|
||||
require("compe").setup {
|
||||
min_length = 0,
|
||||
source = {
|
||||
buffer = true,
|
||||
nvim_lsp = true,
|
||||
nvim_lua = true,
|
||||
}
|
||||
}
|
||||
local utils = require("dln.utils")
|
||||
local check_behind = function()
|
||||
local is_empty = function(col)
|
||||
return col <= 0 or vim.fn.getline("."):sub(col, col):match("%s")
|
||||
end
|
||||
local pos_col = vim.fn.col(".") - 1
|
||||
return is_empty(pos_col) and is_empty(pos_col - 1) and true or false
|
||||
end
|
||||
|
||||
_G.complete = function(pum, empty)
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
return utils.term_codes(pum)
|
||||
elseif check_behind() then
|
||||
return utils.term_codes(empty)
|
||||
else
|
||||
return vim.fn["compe#complete"]()
|
||||
end
|
||||
end
|
||||
|
||||
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')")
|
||||
utils.mapx("is", "<C-e>", "compe#close('<C-e>')")
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
use {
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
branch = "lua",
|
||||
config = function()
|
||||
-- vim.wo.colorcolumn = "100"
|
||||
vim.g.indent_blankline_char = "│"
|
||||
vim.g.indent_blankline_space_char = "⬝"
|
||||
vim.g.indent_blankline_space_char_highlight_list = { 'IndentSpace' }
|
||||
-- vim.g.indent_blankline_char_list = {'|', '¦', '┆', '┊'}
|
||||
vim.g.indent_blankline_buftype_exclude = {"help", "terminal"}
|
||||
vim.g.indent_blankline_filetype_exclude = {"text", "markdown"}
|
||||
-- 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'}
|
||||
end
|
||||
}
|
||||
|
||||
use {
|
||||
'neovim/nvim-lspconfig',
|
||||
config = function()
|
||||
require('dln.lsp-config')
|
||||
local map = require('dln.utils').map
|
||||
map('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>')
|
||||
map('i', '<C-k>', '<Cmd>lua vim.lsp.buf.signature_help()<CR>')
|
||||
map('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>')
|
||||
map('n', '1gd', '<Cmd>lua vim.lsp.buf.type_definition()<CR>')
|
||||
map('n', 'gr', '<Cmd>lua vim.lsp.buf.references()<CR>')
|
||||
map('n', 'g0', '<Cmd>lua vim.lsp.buf.document_symbol()<CR>')
|
||||
map('n', 'gf', '<Cmd>lua vim.lsp.buf.formatting()<CR>')
|
||||
end
|
||||
}
|
||||
|
||||
use {
|
||||
'nvim-telescope/telescope.nvim',
|
||||
requires = {
|
||||
'nvim-lua/popup.nvim',
|
||||
'nvim-lua/plenary.nvim',
|
||||
'nvim-telescope/telescope-fzy-native.nvim',
|
||||
'nvim-telescope/telescope-github.nvim'
|
||||
},
|
||||
config = function()
|
||||
require('dln.telescope')
|
||||
local map = require('dln.utils').map
|
||||
map('n', '<space>', '<cmd>lua require("telescope.builtin").buffers()<CR>')
|
||||
map('n', '<leader>b', '<cmd>lua require("telescope.builtin").buffers()<CR>')
|
||||
map('n', '<leader>f', '<cmd>lua require("telescope.builtin").oldfiles()<CR>')
|
||||
map('n', '<leader>e', '<cmd>lua require("telescope.builtin").git_files()<CR>')
|
||||
map('n', '<leader>s', '<cmd>lua require("telescope.builtin").lsp_document_symbols()<CR>')
|
||||
map('n', '<leader>t', '<cmd>lua require("telescope.builtin").treesitter()<CR>')
|
||||
end
|
||||
}
|
||||
|
||||
use {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
run = ":TSUpdate",
|
||||
requires = {
|
||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||
"windwp/nvim-ts-autotag"
|
||||
},
|
||||
config = function()
|
||||
require("dln.treesitter")
|
||||
vim.wo.foldmethod = "expr"
|
||||
vim.wo.foldexpr = "nvim_treesitter#foldexpr()"
|
||||
end
|
||||
}
|
||||
|
||||
use {
|
||||
"~/src/github.com/shelmangroup/nvim-shelman-theme",
|
||||
requires ={{'tjdevries/colorbuddy.vim'}},
|
||||
config = function()
|
||||
require('colorbuddy').colorscheme('shelman-light')
|
||||
end
|
||||
}
|
||||
|
||||
end)
|
Loading…
Add table
Add a link
Reference in a new issue