Browse Source

null ls

imac
Juni Kim 2 years ago
parent
commit
0028b68d67
  1. 54
      after/plugin/lsp.lua
  2. 2
      after/plugin/lualine.lua
  3. 6
      lua/junikim/options.lua
  4. 2
      lua/junikim/packer.lua

54
after/plugin/lsp.lua

@ -12,17 +12,16 @@ lsp.setup_nvim_cmp({
-- (Optional) Configure lua language server for neovim
lsp.nvim_workspace()
local platform = require("mason-core.platform");
local servers = {
'tailwindcss',
'tsserver',
'texlab',
'pyright',
'efm',
'ltex',
'jsonls'
}
local platform = require("mason-core.platform");
if not (platform.is.linux_x64_musl or
platform.is.linux_arm64_musl)
then
@ -31,15 +30,11 @@ end
lsp.ensure_installed(servers)
lsp.configure("efm", {
settings = {
languages = {
sh = "shellcheck -x",
bash = "shellcheck -x",
zsh = "shellcheck -x",
}
},
filetypes = { "sh", "bash", "zsh" }
lsp.configure("tsserver", {
on_init = function(client)
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentFormattingRangeProvider = false
end
})
lsp.on_attach(function(client, bufnr)
@ -56,3 +51,40 @@ vim.diagnostic.config({
underline = true,
float = true,
})
local null_ls = require('null-ls')
local null_opts = lsp.build_options('null-ls', {})
null_ls.setup({
on_attach = function(client, bufnr)
null_opts.on_attach(client, bufnr)
local format_cmd = function(input)
vim.lsp.buf.format({
id = client.id,
timeout_ms = 5000,
async = input.bang,
})
end
local bufcmd = vim.api.nvim_buf_create_user_command
bufcmd(bufnr, 'NullFormat', format_cmd, {
bang = true,
range = true,
desc = 'Format using null-ls'
})
end,
sources = {
null_ls.builtins.formatting.prettier,
null_ls.builtins.formatting.autopep8,
null_ls.builtins.formatting.gofmt,
null_ls.builtins.diagnostics.eslint,
null_ls.builtins.diagnostics.shellcheck,
}
})
require('mason-null-ls').setup({
ensure_installed = nil,
automatic_installation = true,
automatic_setup = false,
})

2
after/plugin/lualine.lua

@ -2,6 +2,8 @@ local function getWords()
return tostring(vim.fn.wordcount().words) .. " W"
end
vim.opt.laststatus = 3
require('lualine').setup {
options = {
icons_enabled = true,

6
lua/junikim/options.lua

@ -13,16 +13,14 @@ vim.opt.colorcolumn = "80"
vim.opt.list = true
vim.opt.wrap = false
vim.opt.splitbelow = true
vim.opt.splitright = true
vim.opt.splitbelow = false
vim.opt.splitright = false
vim.opt.undodir = vim.fn.stdpath('data') .. "/undodir"
vim.opt.undofile = true
vim.opt.hlsearch = false
vim.opt.incsearch = true
vim.g.airline_theme = "base16_chalk"
vim.g.airline_powerline_fonts = 1
vim.opt.nu = true
vim.opt.rnu = true

2
lua/junikim/packer.lua

@ -45,6 +45,8 @@ return require('packer').startup(function(use)
-- Snippets
{ 'L3MON4D3/LuaSnip' }, -- Required
{ 'rafamadriz/friendly-snippets' }, -- Optional
{ "jose-elias-alvarez/null-ls.nvim", "jay-babu/mason-null-ls.nvim" },
}
}

Loading…
Cancel
Save