Browse Source

bash language server support

macos
Juni Kim 2 years ago
parent
commit
cfc94b7985
  1. 21
      after/plugin/lsp.lua
  2. 27
      after/plugin/telescope.lua
  3. 4
      lua/junikim/init.lua
  4. 23
      lua/junikim/options.lua
  5. 32
      lua/junikim/packer.lua
  6. 2
      lua/junikim/remap.lua
  7. 5
      plugin/packer_compiled.lua

21
after/plugin/lsp.lua

@ -1,6 +1,7 @@
-- Learn the keybindings, see :help lsp-zero-keybindings
-- Learn to configure LSP servers, see :help lsp-zero-api-showcase
local lsp = require('lsp-zero')
local lspconfig = require('lspconfig');
lsp.preset('recommended')
-- (Optional) Configure lua language server for neovim
@ -11,12 +12,28 @@ lsp.ensure_installed({
'tsserver',
'texlab',
'pyright',
'sumneko_lua'
'sumneko_lua',
'efm'
})
lsp.configure("efm", {
settings = {
languages = {
sh = "shellcheck -x"
}
},
filetypes = { "sh" }
})
lsp.on_attach(function(client, bufnr)
local opts = {buffer = bufnr, remap=false}
local opts = { buffer = bufnr, remap = false }
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
end)
lsp.setup()
vim.diagnostic.config({
virtual_text = true,
underline = true,
float = true,
})

27
after/plugin/telescope.lua

@ -1,5 +1,30 @@
local builtin = require("telescope.builtin")
vim.keymap.set('n', '<C-P>', builtin.git_files, {})
local function git_exists()
local path = require("pl.path")
local p = "."
while true do
local gitpath = p .. "/.git"
local d = io.open(gitpath)
if d then
d:close()
return true
else
p = p .. "/.."
end
if path.abspath(p) ~= "/" then
return false
end
end
end
vim.keymap.set('n', '<C-P>', function()
if git_exists() then
builtin.git_files()
else
builtin.find_files()
end
end, {})
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})

4
lua/junikim/init.lua

@ -1,3 +1,3 @@
require("junikim.remap")
require("junikim.options")
require("junikim.packer")
require("junikim.options")
require("junikim.remap")

23
lua/junikim/options.lua

@ -1,3 +1,4 @@
vim.opt.mouse:append('a')
vim.opt.number = true
vim.opt.linebreak = true
vim.opt.shiftwidth = 2
@ -5,13 +6,17 @@ vim.opt.tabstop = 2
vim.opt.softtabstop = 2
vim.opt.expandtab = true
vim.opt.smarttab = true
vim.opt.shiftround = true
vim.opt.autoindent = true
vim.opt.textwidth = 80
vim.opt.colorcolumn = "80"
vim.opt.list = true
vim.g.airline_theme = "base16_chalk"
--vim.g.airline_powerline_fonts = 1
vim.g.airline_powerline_fonts = 1
vim.cmd("filetype plugin indent on")
vim.cmd("filetype on")
vim.api.nvim_create_autocmd("FileType", {
pattern = "python",
@ -25,15 +30,15 @@ vim.api.nvim_create_autocmd("FileType", {
})
vim.api.nvim_create_autocmd("FileType", {
pattern = {"markdown", "tex", "text"},
pattern = { "markdown", "tex", "text" },
callback = function(args)
vim.bo.expandtab = false
vim.o.smarttab = false
vim.bo.autoindent = false
end
})
vim.api.nvim_create_autocmd("FileType", {
pattern = {"c", "cpp", "slang"},
pattern = { "c", "cpp", "slang" },
callback = function(args)
vim.bo.cindent = true
end
@ -48,6 +53,14 @@ vim.api.nvim_create_autocmd("FileType", {
vim.bo.softtabstop = 4
vim.bo.preserveindent = true
vim.bo.copyindent = true
vim.api.nvim_set_keymap("n", "<F4>", ":w|:!cpgo test<CR>", {noremap = true})
vim.bo.formatprg = "gofmt -e -w"
vim.api.nvim_set_keymap("n", "<F4>", ":w|:!cpgo test<CR>", { noremap = true })
end
})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = { "*.go", "*.py", "*.lua", "*.ts", "*.tsx", "*.js", "*.md", "*.json" },
callback = function(args)
vim.lsp.buf.formatting_sync()
end
})

32
lua/junikim/packer.lua

@ -3,9 +3,11 @@ vim.cmd [[packadd packer.nvim]]
return require('packer').startup(function(use)
-- Packer can manage itself
use 'wbthomason/packer.nvim'
use 'tpope/vim-sensible'
use_rocks 'penlight'
use {
'nvim-telescope/telescope.nvim', tag = '0.1.1',
requires = { {'nvim-lua/plenary.nvim'} }
requires = { { 'nvim-lua/plenary.nvim' } }
}
use 'Townk/vim-autoclose'
use {
@ -13,11 +15,11 @@ return require('packer').startup(function(use)
vim.cmd("colorscheme onedark")
end
}
use (
'nvim-treesitter/nvim-treesitter', {run = ':TSUpdate'}
use(
'nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' }
)
use 'nvim-tree/nvim-web-devicons'
use {'romgrk/barbar.nvim', wants = 'nvim-web-devicons'}
use { 'romgrk/barbar.nvim', wants = 'nvim-web-devicons' }
use 'vim-airline/vim-airline'
use 'vim-airline/vim-airline-themes'
use {
@ -25,21 +27,21 @@ return require('packer').startup(function(use)
branch = 'v1.x',
requires = {
-- LSP Support
{'neovim/nvim-lspconfig'}, -- Required
{'williamboman/mason.nvim'}, -- Optional
{'williamboman/mason-lspconfig.nvim'}, -- Optional
{ 'neovim/nvim-lspconfig' }, -- Required
{ 'williamboman/mason.nvim' }, -- Optional
{ 'williamboman/mason-lspconfig.nvim' }, -- Optional
-- Autocompletion
{'hrsh7th/nvim-cmp'}, -- Required
{'hrsh7th/cmp-nvim-lsp'}, -- Required
{'hrsh7th/cmp-buffer'}, -- Optional
{'hrsh7th/cmp-path'}, -- Optional
{'saadparwaiz1/cmp_luasnip'}, -- Optional
{'hrsh7th/cmp-nvim-lua'}, -- Optional
{ 'hrsh7th/nvim-cmp' }, -- Required
{ 'hrsh7th/cmp-nvim-lsp' }, -- Required
{ 'hrsh7th/cmp-buffer' }, -- Optional
{ 'hrsh7th/cmp-path' }, -- Optional
{ 'saadparwaiz1/cmp_luasnip' }, -- Optional
{ 'hrsh7th/cmp-nvim-lua' }, -- Optional
-- Snippets
{'L3MON4D3/LuaSnip'}, -- Required
{'rafamadriz/friendly-snippets'}, -- Optional
{ 'L3MON4D3/LuaSnip' }, -- Required
{ 'rafamadriz/friendly-snippets' }, -- Optional
}
}

2
lua/junikim/remap.lua

@ -1,4 +1,4 @@
function map(mode, lhs, rhs, opts)
local function map(mode, lhs, rhs, opts)
local options = { noremap = true }
if opts then
options = vim.tbl_extend("force", options, opts)

5
plugin/packer_compiled.lua

@ -196,6 +196,11 @@ _G.packer_plugins = {
path = "/home/junikim/.local/share/nvim/site/pack/packer/start/vim-autoclose",
url = "https://github.com/Townk/vim-autoclose"
},
["vim-sensible"] = {
loaded = true,
path = "/home/junikim/.local/share/nvim/site/pack/packer/start/vim-sensible",
url = "https://github.com/tpope/vim-sensible"
},
vimtex = {
loaded = true,
path = "/home/junikim/.local/share/nvim/site/pack/packer/start/vimtex",

Loading…
Cancel
Save