fix styling issues (#811)

This commit is contained in:
Abouzar Parvan 2021-07-09 16:37:25 +04:30 committed by GitHub
parent a9e7b6ff8c
commit 2866ba528c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 170 additions and 176 deletions

View file

@ -7,7 +7,7 @@ vim.g.colors_name = O.colorscheme -- Colorscheme must get called after plugins a
require "lv-utils" require "lv-utils"
require "lv-treesitter" require "lv-treesitter"
if O.plugin.dashboard.active then if O.plugin.dashboard.active then
require("lv-dashboard").config() require("lv-dashboard").config()
end end
-- TODO these gues need to be in language files -- TODO these gues need to be in language files
-- require "lsp" -- require "lsp"

View file

@ -5,19 +5,19 @@ vim.api.nvim_set_keymap("n", "<C-k>", "<C-w>k", { silent = true })
vim.api.nvim_set_keymap("n", "<C-l>", "<C-w>l", { silent = true }) vim.api.nvim_set_keymap("n", "<C-l>", "<C-w>l", { silent = true })
-- Terminal window navigation -- Terminal window navigation
vim.api.nvim_set_keymap("t", "<C-h>", "<C-\\><C-N><C-w>h", {silent = true, noremap = true}) vim.api.nvim_set_keymap("t", "<C-h>", "<C-\\><C-N><C-w>h", { silent = true, noremap = true })
vim.api.nvim_set_keymap("t", "<C-j>", "<C-\\><C-N><C-w>j", {silent = true, noremap = true}) vim.api.nvim_set_keymap("t", "<C-j>", "<C-\\><C-N><C-w>j", { silent = true, noremap = true })
vim.api.nvim_set_keymap("t", "<C-k>", "<C-\\><C-N><C-w>k", {silent = true, noremap = true}) vim.api.nvim_set_keymap("t", "<C-k>", "<C-\\><C-N><C-w>k", { silent = true, noremap = true })
vim.api.nvim_set_keymap("t", "<C-l>", "<C-\\><C-N><C-w>l", {silent = true, noremap = true}) vim.api.nvim_set_keymap("t", "<C-l>", "<C-\\><C-N><C-w>l", { silent = true, noremap = true })
vim.api.nvim_set_keymap("i", "<C-h>", "<C-\\><C-N><C-w>h", {silent = true, noremap = true}) vim.api.nvim_set_keymap("i", "<C-h>", "<C-\\><C-N><C-w>h", { silent = true, noremap = true })
vim.api.nvim_set_keymap("i", "<C-j>", "<C-\\><C-N><C-w>j", {silent = true, noremap = true}) vim.api.nvim_set_keymap("i", "<C-j>", "<C-\\><C-N><C-w>j", { silent = true, noremap = true })
vim.api.nvim_set_keymap("i", "<C-k>", "<C-\\><C-N><C-w>k", {silent = true, noremap = true}) vim.api.nvim_set_keymap("i", "<C-k>", "<C-\\><C-N><C-w>k", { silent = true, noremap = true })
vim.api.nvim_set_keymap("i", "<C-l>", "<C-\\><C-N><C-w>l", {silent = true, noremap = true}) vim.api.nvim_set_keymap("i", "<C-l>", "<C-\\><C-N><C-w>l", { silent = true, noremap = true })
vim.api.nvim_set_keymap("t", "<Esc>", "<C-\\><C-n>", {silent = true, noremap = true}) vim.api.nvim_set_keymap("t", "<Esc>", "<C-\\><C-n>", { silent = true, noremap = true })
-- TODO fix this -- TODO fix this
-- resize with arrows -- resize with arrows
if vim.fn.has("mac") == 1 then if vim.fn.has "mac" == 1 then
vim.api.nvim_set_keymap("n", "<A-Up>", ":resize -2<CR>", { silent = true }) vim.api.nvim_set_keymap("n", "<A-Up>", ":resize -2<CR>", { silent = true })
vim.api.nvim_set_keymap("n", "<A-Down>", ":resize +2<CR>", { silent = true }) vim.api.nvim_set_keymap("n", "<A-Down>", ":resize +2<CR>", { silent = true })
vim.api.nvim_set_keymap("n", "<A-Left>", ":vertical resize -2<CR>", { silent = true }) vim.api.nvim_set_keymap("n", "<A-Left>", ":vertical resize -2<CR>", { silent = true })

View file

@ -1,6 +1,6 @@
-- TODO find correct root filetype -- TODO find correct root filetype
-- :LspInstall angular -- :LspInstall angular
require'lspconfig'.angularls.setup { require("lspconfig").angularls.setup {
cmd = {DATA_PATH .. "/lspinstall/angular/node_modules/@angular/language-server/bin/ngserver", "--stdio"}, cmd = { DATA_PATH .. "/lspinstall/angular/node_modules/@angular/language-server/bin/ngserver", "--stdio" },
on_attach = require'lsp'.common_on_attach, on_attach = require("lsp").common_on_attach,
} }

View file

@ -2,22 +2,22 @@
-- return -- return
-- end -- end
local nvim_lsp = require'lspconfig' local nvim_lsp = require "lspconfig"
local configs = require'lspconfig/configs' local configs = require "lspconfig/configs"
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true capabilities.textDocument.completion.completionItem.snippetSupport = true
configs.emmet_ls = { configs.emmet_ls = {
default_config = { default_config = {
cmd = {'emmet-ls', '--stdio'}; cmd = { "emmet-ls", "--stdio" },
filetypes = {'html', 'css', 'javascript', 'typescript'}; filetypes = { "html", "css", "javascript", "typescript" },
root_dir = function() root_dir = function()
return vim.loop.cwd() return vim.loop.cwd()
end; end,
settings = {}; settings = {},
}; },
} }
nvim_lsp.emmet_ls.setup{ nvim_lsp.emmet_ls.setup {
-- on_attach = on_attach; -- on_attach = on_attach;
} }

View file

@ -1,85 +1,79 @@
-- TODO figure out why this don't work -- TODO figure out why this don't work
vim.fn.sign_define( vim.fn.sign_define(
"LspDiagnosticsSignError", "LspDiagnosticsSignError",
{texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError"} { texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError" }
) )
vim.fn.sign_define( vim.fn.sign_define(
"LspDiagnosticsSignWarning", "LspDiagnosticsSignWarning",
{texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"} { texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning" }
) )
vim.fn.sign_define( vim.fn.sign_define(
"LspDiagnosticsSignHint", "LspDiagnosticsSignHint",
{texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"} { texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint" }
) )
vim.fn.sign_define( vim.fn.sign_define(
"LspDiagnosticsSignInformation", "LspDiagnosticsSignInformation",
{texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"} { texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation" }
) )
vim.cmd("nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>") vim.cmd "nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>"
vim.cmd("nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>") vim.cmd "nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>"
vim.cmd("nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>") vim.cmd "nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>"
vim.cmd("nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>") vim.cmd "nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>"
vim.cmd("nnoremap <silent> K :lua vim.lsp.buf.hover()<CR>") vim.cmd "nnoremap <silent> K :lua vim.lsp.buf.hover()<CR>"
-- vim.cmd('nnoremap <silent> <C-k> <cmd>lua vim.lsp.buf.signature_help()<CR>') -- vim.cmd('nnoremap <silent> <C-k> <cmd>lua vim.lsp.buf.signature_help()<CR>')
vim.cmd("nnoremap <silent> <C-p> :lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = O.lsp.popup_border}})<CR>") vim.cmd "nnoremap <silent> <C-p> :lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = O.lsp.popup_border}})<CR>"
vim.cmd("nnoremap <silent> <C-n> :lua vim.lsp.diagnostic.goto_next({popup_opts = {border = O.lsp.popup_border}})<CR>") vim.cmd "nnoremap <silent> <C-n> :lua vim.lsp.diagnostic.goto_next({popup_opts = {border = O.lsp.popup_border}})<CR>"
-- scroll down hover doc or scroll in definition preview -- scroll down hover doc or scroll in definition preview
-- scroll up hover doc -- scroll up hover doc
vim.cmd('command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()') vim.cmd 'command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()'
-- Set Default Prefix. -- Set Default Prefix.
-- Note: You can set a prefix per lsp server in the lv-globals.lua file -- Note: You can set a prefix per lsp server in the lv-globals.lua file
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
vim.lsp.diagnostic.on_publish_diagnostics, { virtual_text = {
virtual_text = { prefix = "",
prefix = "", spacing = 0,
spacing = 0, },
}, signs = true,
signs = true, underline = true,
underline = true, })
}
)
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with( vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
vim.lsp.handlers.hover, { border = O.lsp.popup_border,
border = O.lsp.popup_border })
}
)
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with( vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
vim.lsp.handlers.signature_help, { border = O.lsp.popup_border,
border = O.lsp.popup_border })
}
)
-- symbols for autocomplete -- symbols for autocomplete
vim.lsp.protocol.CompletionItemKind = { vim.lsp.protocol.CompletionItemKind = {
"  (Text) ", "  (Text) ",
"  (Method)", "  (Method)",
"  (Function)", "  (Function)",
"  (Constructor)", "  (Constructor)",
" ﴲ (Field)", " ﴲ (Field)",
"[] (Variable)", "[] (Variable)",
"  (Class)", "  (Class)",
" ﰮ (Interface)", " ﰮ (Interface)",
"  (Module)", "  (Module)",
" 襁 (Property)", " 襁 (Property)",
"  (Unit)", "  (Unit)",
"  (Value)", "  (Value)",
" 練 (Enum)", " 練 (Enum)",
"  (Keyword)", "  (Keyword)",
"  (Snippet)", "  (Snippet)",
"  (Color)", "  (Color)",
"  (File)", "  (File)",
"  (Reference)", "  (Reference)",
"  (Folder)", "  (Folder)",
"  (EnumMember)", "  (EnumMember)",
" ﲀ (Constant)", " ﲀ (Constant)",
" ﳤ (Struct)", " ﳤ (Struct)",
"  (Event)", "  (Event)",
"  (Operator)", "  (Operator)",
"  (TypeParameter)" "  (TypeParameter)",
} }
--[[ " autoformat --[[ " autoformat
@ -90,10 +84,10 @@ autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100) ]]
-- autocmd FileType java nnoremap ca <Cmd>lua require('jdtls').code_action()<CR> -- autocmd FileType java nnoremap ca <Cmd>lua require('jdtls').code_action()<CR>
local function documentHighlight(client, bufnr) local function documentHighlight(client, bufnr)
-- Set autocommands conditional on server_capabilities -- Set autocommands conditional on server_capabilities
if client.resolved_capabilities.document_highlight then if client.resolved_capabilities.document_highlight then
vim.api.nvim_exec( vim.api.nvim_exec(
[[ [[
hi LspReferenceRead cterm=bold ctermbg=red guibg=#464646 hi LspReferenceRead cterm=bold ctermbg=red guibg=#464646
hi LspReferenceText cterm=bold ctermbg=red guibg=#464646 hi LspReferenceText cterm=bold ctermbg=red guibg=#464646
hi LspReferenceWrite cterm=bold ctermbg=red guibg=#464646 hi LspReferenceWrite cterm=bold ctermbg=red guibg=#464646
@ -103,69 +97,68 @@ local function documentHighlight(client, bufnr)
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references() autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
augroup END augroup END
]], ]],
false false
) )
end end
end end
local lsp_config = {} local lsp_config = {}
if O.document_highlight then if O.document_highlight then
function lsp_config.common_on_attach(client, bufnr) function lsp_config.common_on_attach(client, bufnr)
documentHighlight(client, bufnr) documentHighlight(client, bufnr)
end end
end end
function lsp_config.tsserver_on_attach(client, bufnr) function lsp_config.tsserver_on_attach(client, bufnr)
-- lsp_config.common_on_attach(client, bufnr) -- lsp_config.common_on_attach(client, bufnr)
client.resolved_capabilities.document_formatting = false client.resolved_capabilities.document_formatting = false
local ts_utils = require("nvim-lsp-ts-utils") local ts_utils = require "nvim-lsp-ts-utils"
-- defaults -- defaults
ts_utils.setup { ts_utils.setup {
debug = false, debug = false,
disable_commands = false, disable_commands = false,
enable_import_on_completion = false, enable_import_on_completion = false,
import_all_timeout = 5000, -- ms import_all_timeout = 5000, -- ms
-- eslint -- eslint
eslint_enable_code_actions = true, eslint_enable_code_actions = true,
eslint_enable_disable_comments = true, eslint_enable_disable_comments = true,
eslint_bin = O.lang.tsserver.linter, eslint_bin = O.lang.tsserver.linter,
eslint_config_fallback = nil, eslint_config_fallback = nil,
eslint_enable_diagnostics = true, eslint_enable_diagnostics = true,
-- formatting -- formatting
enable_formatting = O.lang.tsserver.autoformat, enable_formatting = O.lang.tsserver.autoformat,
formatter = O.lang.tsserver.formatter, formatter = O.lang.tsserver.formatter,
formatter_config_fallback = nil, formatter_config_fallback = nil,
-- parentheses completion -- parentheses completion
complete_parens = false, complete_parens = false,
signature_help_in_parens = false, signature_help_in_parens = false,
-- update imports on file move -- update imports on file move
update_imports_on_move = false, update_imports_on_move = false,
require_confirmation_on_move = false, require_confirmation_on_move = false,
watch_dir = nil, watch_dir = nil,
} }
-- required to fix code action ranges -- required to fix code action ranges
ts_utils.setup_client(client) ts_utils.setup_client(client)
-- TODO: keymap these? -- TODO: keymap these?
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "gs", ":TSLspOrganize<CR>", {silent = true}) -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gs", ":TSLspOrganize<CR>", {silent = true})
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "qq", ":TSLspFixCurrent<CR>", {silent = true}) -- vim.api.nvim_buf_set_keymap(bufnr, "n", "qq", ":TSLspFixCurrent<CR>", {silent = true})
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", ":TSLspRenameFile<CR>", {silent = true}) -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", ":TSLspRenameFile<CR>", {silent = true})
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", ":TSLspImportAll<CR>", {silent = true}) -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", ":TSLspImportAll<CR>", {silent = true})
end end
require("lv-utils").define_augroups {
require('lv-utils').define_augroups({ _general_lsp = {
_general_lsp = { { "FileType", "lspinfo", "nnoremap <silent> <buffer> q :q<CR>" },
{'FileType', 'lspinfo', 'nnoremap <silent> <buffer> q :q<CR>'}, },
} }
})
-- Use a loop to conveniently both setup defined servers -- Use a loop to conveniently both setup defined servers
-- and map buffer local keybindings when the language server attaches -- and map buffer local keybindings when the language server attaches

View file

@ -1,5 +1,5 @@
-- TODO what is a svelte filetype -- TODO what is a svelte filetype
require'lspconfig'.svelte.setup { require("lspconfig").svelte.setup {
cmd = {DATA_PATH .. "/lspinstall/svelte/node_modules/.bin/svelteserver", "--stdio"}, cmd = { DATA_PATH .. "/lspinstall/svelte/node_modules/.bin/svelteserver", "--stdio" },
on_attach = require'lsp'.common_on_attach on_attach = require("lsp").common_on_attach,
} }

View file

@ -1,12 +1,13 @@
-- TODO what is a tailwindcss filetype -- TODO what is a tailwindcss filetype
local lspconfig = require 'lspconfig' local lspconfig = require "lspconfig"
lspconfig.tailwindcss.setup { lspconfig.tailwindcss.setup {
cmd = { cmd = {
"node", DATA_PATH .. "/lspinstall/tailwindcss/tailwindcss-intellisense/extension/dist/server/tailwindServer.js", "node",
"--stdio" DATA_PATH .. "/lspinstall/tailwindcss/tailwindcss-intellisense/extension/dist/server/tailwindServer.js",
}, "--stdio",
filetypes = O.lang.tailwindcss.filetypes, },
root_dir = require("lspconfig/util").root_pattern("tailwind.config.js", "postcss.config.ts", ".postcssrc"), filetypes = O.lang.tailwindcss.filetypes,
on_attach = require'lsp'.common_on_attach root_dir = require("lspconfig/util").root_pattern("tailwind.config.js", "postcss.config.ts", ".postcssrc"),
on_attach = require("lsp").common_on_attach,
} }

View file

@ -3,35 +3,35 @@
local M = {} local M = {}
M.setup = function() M.setup = function()
local tsserver_args = {} local tsserver_args = {}
local prettier = { local prettier = {
formatCommand = "prettier --stdin-filepath ${INPUT}", formatCommand = "prettier --stdin-filepath ${INPUT}",
formatStdin = true formatStdin = true,
}
if vim.fn.glob "node_modules/.bin/prettier" ~= "" then
prettier = {
formatCommand = "./node_modules/.bin/prettier --stdin-filepath ${INPUT}",
formatStdin = true,
} }
end
if vim.fn.glob("node_modules/.bin/prettier") ~= "" then require("lspconfig").efm.setup {
prettier = { -- init_options = {initializationOptions},
formatCommand = "./node_modules/.bin/prettier --stdin-filepath ${INPUT}", cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" },
formatStdin = true init_options = { documentFormatting = true, codeAction = false },
} filetypes = { "html", "css", "yaml", "vue", "javascript", "javascriptreact", "typescript", "typescriptreact" },
end settings = {
rootMarkers = { ".git/", "package.json" },
require"lspconfig".efm.setup { languages = {
-- init_options = {initializationOptions}, html = { prettier },
cmd = {DATA_PATH .. "/lspinstall/efm/efm-langserver"}, css = { prettier },
init_options = {documentFormatting = true, codeAction = false}, json = { prettier },
filetypes = {"html", "css", "yaml", "vue", "javascript", "javascriptreact", "typescript", "typescriptreact"}, yaml = { prettier },
settings = { },
rootMarkers = {".git/", "package.json"}, },
languages = { }
html = {prettier},
css = {prettier},
json = {prettier},
yaml = {prettier}
}
}
}
end end
return M return M

View file

@ -36,7 +36,7 @@ telescope.setup {
file_sorter = require("telescope.sorters").get_fzy_sorter, file_sorter = require("telescope.sorters").get_fzy_sorter,
file_ignore_patterns = {}, file_ignore_patterns = {},
generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter,
path_display = {"shorten"}, path_display = { "shorten" },
winblend = 0, winblend = 0,
border = {}, border = {},
borderchars = { "", "", "", "", "", "", "", "" }, borderchars = { "", "", "", "", "", "", "", "" },

View file

@ -21,7 +21,7 @@ which_key.setup {
z = true, -- bindings for folds, spelling and others prefixed with z z = true, -- bindings for folds, spelling and others prefixed with z
g = true, -- bindings for prefixed with g g = true, -- bindings for prefixed with g
}, },
spelling = {enabled = true, suggestions = 20}, -- use which-key for spelling hints spelling = { enabled = true, suggestions = 20 }, -- use which-key for spelling hints
}, },
icons = { icons = {
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
@ -88,7 +88,7 @@ vim.api.nvim_set_keymap("n", "<leader>c", ":BufferClose<CR>", { noremap = true,
-- Save -- Save
vim.api.nvim_set_keymap("n", "<leader>w", ":w!<CR>", { noremap = true, silent = true }) vim.api.nvim_set_keymap("n", "<leader>w", ":w!<CR>", { noremap = true, silent = true })
-- Quit -- Quit
vim.api.nvim_set_keymap("n", "<leader>q", ":q!<CR>", { noremap = true, silent = true }) vim.api.nvim_set_keymap("n", "<leader>q", ":q!<CR>", { noremap = true, silent = true })
-- open lv-config -- open lv-config

View file

@ -11,8 +11,8 @@ cmd "set inccommand=split"
cmd "set iskeyword+=-" cmd "set iskeyword+=-"
cmd "set whichwrap+=<,>,[,],h,l" cmd "set whichwrap+=<,>,[,],h,l"
if O.transparent_window then if O.transparent_window then
cmd "au ColorScheme * hi Normal ctermbg=none guibg=none" cmd "au ColorScheme * hi Normal ctermbg=none guibg=none"
cmd "au ColorScheme * hi SignColumn ctermbg=none guibg=none" cmd "au ColorScheme * hi SignColumn ctermbg=none guibg=none"
end end
--- SETTINGS --- --- SETTINGS ---
@ -21,7 +21,7 @@ opt.backup = false -- creates a backup file
opt.clipboard = O.clipboard -- allows neovim to access the system clipboard opt.clipboard = O.clipboard -- allows neovim to access the system clipboard
opt.cmdheight = O.cmdheight -- more space in the neovim command line for displaying messages opt.cmdheight = O.cmdheight -- more space in the neovim command line for displaying messages
opt.colorcolumn = "99999" -- fix indentline for now opt.colorcolumn = "99999" -- fix indentline for now
opt.completeopt = {"menuone", "noselect"} opt.completeopt = { "menuone", "noselect" }
opt.conceallevel = 0 -- so that `` is visible in markdown files opt.conceallevel = 0 -- so that `` is visible in markdown files
opt.fileencoding = "utf-8" -- the encoding written to a file opt.fileencoding = "utf-8" -- the encoding written to a file
opt.guifont = "monospace:h17" -- the font used in graphical neovim applications opt.guifont = "monospace:h17" -- the font used in graphical neovim applications