Install efm lsp and use lua-format on all files

This commit is contained in:
2021-11-21 12:37:26 +03:00
parent cb8c78723b
commit 05606ee54b
9 changed files with 83 additions and 101 deletions

View File

@@ -2,24 +2,12 @@ require("nvim-tree").setup({
open_on_setup = true,
hijack_cursor = true,
update_cwd = true,
update_focused_file = {
enable = true
},
view = {
width = 30,
side = "left",
auto_resize = true
},
filters = {
custom = { ".git" }
}
update_focused_file = { enable = true },
view = { width = 30, side = "left", auto_resize = true },
filters = { custom = { ".git" } }
})
vim.g.nvim_tree_add_trailing = 1
vim.g.nvim_tree_indent_markers = 1
vim.g.nvim_tree_show_icons = {
git = 0,
folders = 0,
files = 0,
folder_arrows = 0
}
vim.g.nvim_tree_show_icons = { git = 0, folders = 0, files = 0, folder_arrows = 0 }

View File

@@ -32,6 +32,6 @@ vim.api.nvim_exec([[
]], false)
-- Automatically formatting buffer on save
vim.api.nvim_command("autocmd BufWritePre * lua vim.lsp.buf.formatting_sync()")
vim.api.nvim_command("autocmd BufWritePre * lua vim.lsp.buf.formatting_sync(nil, 100)")
vim.cmd('command! ToggleBackground lua require("utils").toggleBackground()')

View File

@@ -45,50 +45,64 @@ cmp.setup({
['<C-k>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
['<TAB>'] = cmp.mapping.confirm({ behavior = cmp.SelectBehavior.Insert })
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "nvim_lua" },
{ name = "path" },
{ name = "buffer", keyword_length = 5 }
},
completion = {
completeopt = "menu,menuone,noselect,noinsert"
},
sources = { { name = "nvim_lsp" }, { name = "luasnip" }, { name = "nvim_lua" }, { name = "path" }, { name = "buffer", keyword_length = 5 } },
completion = { completeopt = "menu,menuone,noselect,noinsert" },
formatting = {
format = function(entry, vim_item)
vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind)
vim_item.menu = ({
buffer = "[Buffer]",
nvim_lsp = "[LSP]",
luasnip = "[Snippet]",
nvim_lua = "[Lua]",
path = "[File]"
})[entry.source.name]
vim_item.menu = ({ buffer = "[Buffer]", nvim_lsp = "[LSP]", luasnip = "[Snippet]", nvim_lua = "[Lua]", path = "[File]" })[entry.source.name]
return vim_item
end
},
experimental = {
ghost_text = true
},
documentation = {
border = { "", "", "", "", "", "", "", "" },
},
sorting = {
comparators = cmp.config.compare.recently_used
}
experimental = { ghost_text = true },
documentation = { border = { "", "", "", "", "", "", "", "" } },
sorting = { comparators = cmp.config.compare.recently_used }
})
local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities())
lsp_installer.on_server_ready(function(server)
local opts = {
capabilities = capabilities
}
local opts = { capabilities = capabilities }
require("lsp_signature").setup({
bind = true,
})
if server.name == "sumneko_lua" then
opts = {
capabilities = capabilities,
settings = {
Lua = {
runtime = { version = "LuaJIT", path = vim.split(package.path, ";") },
diagnostics = { globals = { "vim" } },
workspace = {
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true,
[vim.fn.expand("$HOME/.local/share/nvim/site/pack/packer/start")] = true
}
}
}
}
}
end
if server.name == "efm" then
opts = {
capabilities = capabilities,
init_options = { documentFormatting = true },
filetypes = { "lua" },
settings = {
rootMarkers = { ".git/" },
languages = {
lua = {
{
formatCommand = "lua-format -i --no-keep-simple-function-one-line --no-break-after-operator --column-limit=150 --break-after-table-lb --tab-width 2 --indent-width 2 --spaces-inside-table-braces",
formatStdin = true
}
}
}
}
}
end
require("lsp_signature").setup({ bind = true })
server:setup(opts)
end)

View File

@@ -11,11 +11,7 @@ require("colorizer").setup()
-- Git
require("gitsigns").setup({
current_line_blame = true,
current_line_blame_opts = {
virt_text = true,
virt_text_pos = "eol",
delay = 500
},
current_line_blame_opts = { virt_text = true, virt_text_pos = "eol", delay = 500 },
keymaps = {
noremap = true,
["n <leader>gs"] = '<cmd>lua require("gitsigns").stage_hunk()<CR>',
@@ -24,9 +20,6 @@ require("gitsigns").setup({
}
})
require("iswap").setup({
keys = "1234567890",
autoswap = true
})
require("iswap").setup({ keys = "1234567890", autoswap = true })
require("focus").setup()

View File

@@ -10,12 +10,18 @@ return require("packer").startup(function(use)
use({ "windwp/nvim-ts-autotag" })
use({ "JoosepAlviste/nvim-ts-context-commentstring" })
use({ "nvim-treesitter/playground" })
use({ "folke/twilight.nvim", config = function()
use({
"folke/twilight.nvim",
config = function()
require("twilight").setup({})
end })
use({ "folke/zen-mode.nvim", config = function()
end
})
use({
"folke/zen-mode.nvim",
config = function()
require("zen-mode").setup({})
end })
end
})
-- Make commenting code great
use({ "tpope/vim-commentary" })
@@ -32,14 +38,12 @@ return require("packer").startup(function(use)
-- LSP
use({ "neovim/nvim-lspconfig", "williamboman/nvim-lsp-installer", "onsails/lspkind-nvim" })
use({ "hrsh7th/nvim-cmp", requires = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"hrsh7th/cmp-nvim-lua",
"saadparwaiz1/cmp_luasnip"
}})
use({
"hrsh7th/nvim-cmp",
requires = {
"hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", "hrsh7th/cmp-cmdline", "hrsh7th/cmp-nvim-lua", "saadparwaiz1/cmp_luasnip"
}
})
-- Snippets
use({ "L3MON4D3/LuaSnip" })
@@ -71,19 +75,16 @@ return require("packer").startup(function(use)
-- Show indent lines
use({
"lukas-reineke/indent-blankline.nvim",
config = function ()
config = function()
vim.cmd("let g:indent_blankline_filetype_exclude = ['help']")
require("indent_blankline").setup({
char = "|",
buftype_exclude = { "terminal" },
})
require("indent_blankline").setup({ char = "|", buftype_exclude = { "terminal" } })
end
})
-- Fast movement
use({
"ggandor/lightspeed.nvim",
config = function ()
config = function()
require("lightspeed").setup()
end
})

View File

@@ -4,7 +4,7 @@ local ls = require("luasnip")
ls.config.set_config({
history = true,
-- Update more often, :h events for more info.
updateevents = "TextChanged,TextChangedI",
updateevents = "TextChanged,TextChangedI"
})
require("luasnip/loaders/from_vscode").lazy_load()

View File

@@ -1,6 +1,2 @@
require("telescope").setup({
defaults = {
sorting_strategy = "ascending",
file_ignore_patterns = { ".git", "node_modules" }
}
})
require("telescope").setup({ defaults = { sorting_strategy = "ascending", file_ignore_patterns = { ".git", "node_modules" } } })

View File

@@ -1,16 +1,6 @@
require("nvim-treesitter.configs").setup({
highlight = {
enable = true
},
rainbow = {
enable = true,
extended_mode = true,
disable = { "html" }
},
autotag = {
enable = true
},
context_commentstring = {
enable = true
}
highlight = { enable = true },
rainbow = { enable = true, extended_mode = true, disable = { "html" } },
autotag = { enable = true },
context_commentstring = { enable = true }
})

View File

@@ -1,6 +1,6 @@
local M = {}
M.toggleBackground = function ()
M.toggleBackground = function()
if vim.opt.background:get() == "dark" then
vim.opt.background = "light"
else