terminal-life/nvim: lint vim files, add recent command telescope
This commit is contained in:
parent
a1670dcb3d
commit
50c182d827
|
@ -6,7 +6,8 @@ end_of_line = lf
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
indent_style = tab
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
# Ignore diffs/patches
|
# Ignore diffs/patches
|
||||||
[*.{diff,patch}]
|
[*.{diff,patch}]
|
||||||
|
@ -19,8 +20,8 @@ indent_style = unset
|
||||||
indent_size = unset
|
indent_size = unset
|
||||||
|
|
||||||
[{.*,secrets}/**]
|
[{.*,secrets}/**]
|
||||||
end_of_line = unset
|
end_of_line = false
|
||||||
insert_final_newline = unset
|
insert_final_newline = false
|
||||||
trim_trailing_whitespace = unset
|
trim_trailing_whitespace = unset
|
||||||
charset = unset
|
charset = unset
|
||||||
indent_style = unset
|
indent_style = unset
|
||||||
|
|
|
@ -4,45 +4,45 @@ local luasnip = require 'luasnip'
|
||||||
|
|
||||||
local cmp = require 'cmp'
|
local cmp = require 'cmp'
|
||||||
cmp.setup {
|
cmp.setup {
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
require('luasnip').lsp_expand(args.body)
|
require('luasnip').lsp_expand(args.body)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
mapping = {
|
mapping = {
|
||||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
['<C-Space>'] = cmp.mapping.complete(),
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
['<C-e>'] = cmp.mapping.close(),
|
['<C-e>'] = cmp.mapping.close(),
|
||||||
['<CR>'] = cmp.mapping.confirm {
|
['<CR>'] = cmp.mapping.confirm {
|
||||||
behavior = cmp.ConfirmBehavior.Replace,
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
select = true,
|
select = true,
|
||||||
},
|
},
|
||||||
['<Tab>'] = function(fallback)
|
['<Tab>'] = function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_next_item()
|
cmp.select_next_item()
|
||||||
elseif luasnip.expand_or_jumpable() then
|
elseif luasnip.expand_or_jumpable() then
|
||||||
luasnip.expand_or_jump()
|
luasnip.expand_or_jump()
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
['<S-Tab>'] = function(fallback)
|
['<S-Tab>'] = function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_prev_item()
|
cmp.select_prev_item()
|
||||||
elseif luasnip.jumpable(-1) then
|
elseif luasnip.jumpable(-1) then
|
||||||
luasnip.jump(-1)
|
luasnip.jump(-1)
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
{ name = 'luasnip' },
|
{ name = 'luasnip' },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -23,39 +23,39 @@ vim.api.nvim_set_keymap('n', '<leader>dq', '<cmd>lua vim.diagnostic.setloclist()
|
||||||
vim.api.nvim_set_keymap('n', '<leader>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
vim.api.nvim_set_keymap('n', '<leader>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||||
|
|
||||||
local on_attach = function(client, bufnr)
|
local on_attach = function(client, bufnr)
|
||||||
-- Enable completion triggered by <c-x><c-o>
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
|
|
||||||
-- Mappings (available if LSP is configured and attached to buffer)
|
-- Mappings (available if LSP is configured and attached to buffer)
|
||||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||||
|
|
||||||
-- Show diagnostic popup on cursor hold
|
-- Show diagnostic popup on cursor hold
|
||||||
vim.api.nvim_create_autocmd("CursorHold", {
|
vim.api.nvim_create_autocmd("CursorHold", {
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
callback = function()
|
callback = function()
|
||||||
local opts = {
|
local opts = {
|
||||||
focusable = false,
|
focusable = false,
|
||||||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
||||||
border = 'rounded',
|
border = 'rounded',
|
||||||
source = 'always',
|
source = 'always',
|
||||||
prefix = ' ',
|
prefix = ' ',
|
||||||
scope = 'cursor',
|
scope = 'cursor',
|
||||||
}
|
}
|
||||||
vim.diagnostic.open_float(nil, opts)
|
vim.diagnostic.open_float(nil, opts)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -65,23 +65,23 @@ local CAPABILITIES = require('cmp_nvim_lsp').default_capabilities()
|
||||||
|
|
||||||
--- Event handlers
|
--- Event handlers
|
||||||
local HANDLERS = {
|
local HANDLERS = {
|
||||||
-- TODO: replace with vim.lsp.protocol.Methods
|
-- TODO: replace with vim.lsp.protocol.Methods
|
||||||
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, FLOAT_CONFIG),
|
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, FLOAT_CONFIG),
|
||||||
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, FLOAT_CONFIG),
|
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, FLOAT_CONFIG),
|
||||||
}
|
}
|
||||||
|
|
||||||
-- vscode HTML lsp needs this https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#html
|
-- vscode HTML lsp needs this https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#html
|
||||||
CAPABILITIES.textDocument.completion.completionItem.snippetSupport = true
|
CAPABILITIES.textDocument.completion.completionItem.snippetSupport = true
|
||||||
|
|
||||||
local function setup(lsp, config)
|
local function setup(lsp, config)
|
||||||
if config == nil then
|
if config == nil then
|
||||||
config = {}
|
config = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
config.capabilities = CAPABILITIES
|
config.capabilities = CAPABILITIES
|
||||||
config.handlers = HANDLERS
|
config.handlers = HANDLERS
|
||||||
config.on_attach = on_attach
|
config.on_attach = on_attach
|
||||||
lspconfig[lsp].setup(config)
|
lspconfig[lsp].setup(config)
|
||||||
end
|
end
|
||||||
|
|
||||||
setup('nixd')
|
setup('nixd')
|
||||||
|
@ -96,28 +96,28 @@ setup('svelte')
|
||||||
setup('html')
|
setup('html')
|
||||||
setup('yamlls')
|
setup('yamlls')
|
||||||
setup('jsonls', {
|
setup('jsonls', {
|
||||||
json = {
|
json = {
|
||||||
schemas = require('schemastore').json.schemas(),
|
schemas = require('schemastore').json.schemas(),
|
||||||
validate = {
|
validate = {
|
||||||
enable = true
|
enable = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
setup('gopls', {
|
setup('gopls', {
|
||||||
settings = {
|
settings = {
|
||||||
gopls = { semanticTokens = true }
|
gopls = { semanticTokens = true }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
setup('phpactor')
|
setup('phpactor')
|
||||||
setup('pylsp')
|
setup('pylsp')
|
||||||
setup('solargraph') -- ruby
|
setup('solargraph') -- ruby
|
||||||
setup('rust_analyzer', {
|
setup('rust_analyzer', {
|
||||||
settings = {
|
settings = {
|
||||||
['rust-analyzer'] = {
|
['rust-analyzer'] = {
|
||||||
checkOnSave = { extraArgs = { "--target-dir", "/tmp/rust-analyzer-check" } },
|
checkOnSave = { extraArgs = { "--target-dir", "/tmp/rust-analyzer-check" } },
|
||||||
diagnostics = { disabled = { 'inactive-code' } },
|
diagnostics = { disabled = { 'inactive-code' } },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
setup('sqlls')
|
setup('sqlls')
|
||||||
setup('salt_ls')
|
setup('salt_ls')
|
||||||
|
@ -128,22 +128,22 @@ setup('terraformls')
|
||||||
|
|
||||||
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#denols
|
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#denols
|
||||||
vim.g.markdown_fenced_languages = {
|
vim.g.markdown_fenced_languages = {
|
||||||
"ts=typescript"
|
"ts=typescript"
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Configure diagnostics
|
-- Configure diagnostics
|
||||||
vim.diagnostic.config({
|
vim.diagnostic.config({
|
||||||
virtual_text = false,
|
virtual_text = false,
|
||||||
signs = true,
|
signs = true,
|
||||||
underline = true,
|
underline = true,
|
||||||
update_in_insert = false,
|
update_in_insert = false,
|
||||||
severity_sort = false,
|
severity_sort = false,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Change diagnostic symbols in the sign column (gutter)
|
-- Change diagnostic symbols in the sign column (gutter)
|
||||||
local signs = { Error = "x ", Warn = "! ", Hint = "? ", Info = "i " }
|
local signs = { Error = "x ", Warn = "! ", Hint = "? ", Info = "i " }
|
||||||
for type, icon in pairs(signs) do
|
for type, icon in pairs(signs) do
|
||||||
local hl = "DiagnosticSign" .. type
|
local hl = "DiagnosticSign" .. type
|
||||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
|
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
|
||||||
end
|
end
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -54,21 +54,26 @@ telescope.setup{
|
||||||
defaults = {
|
defaults = {
|
||||||
mappings = {
|
mappings = {
|
||||||
n = {
|
n = {
|
||||||
["k"] = actions.move_selection_next,
|
["k"] = actions.move_selection_next,
|
||||||
["i"] = actions.move_selection_previous,
|
["i"] = actions.move_selection_previous,
|
||||||
["I"] = actions.move_to_top,
|
["I"] = actions.move_to_top,
|
||||||
["K"] = actions.move_to_bottom,
|
["K"] = actions.move_to_bottom,
|
||||||
["<C-c>"] = actions.close,
|
["<C-c>"] = actions.close,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
pickers = {
|
||||||
|
find_files = {
|
||||||
|
-- `hidden = true` will still show the inside of `.git/` as it's not `.gitignore`d.
|
||||||
|
find_command = { "rg", "--files", "--hidden", "--glob", "!**/.git/*" },
|
||||||
|
},
|
||||||
|
},
|
||||||
extensions = {
|
extensions = {
|
||||||
fzf = {
|
fzf = {
|
||||||
fuzzy = true, -- false will only do exact matching
|
fuzzy = true, -- false will only do exact matching
|
||||||
override_generic_sorter = true, -- override the generic sorter
|
override_generic_sorter = true, -- override the generic sorter
|
||||||
override_file_sorter = true, -- override the file sorter
|
override_file_sorter = true, -- override the file sorter
|
||||||
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
|
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
|
||||||
-- the default case_mode is "smart_case"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,6 +85,7 @@ vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
|
||||||
vim.keymap.set('n', '<leader>f/', builtin.live_grep, {})
|
vim.keymap.set('n', '<leader>f/', builtin.live_grep, {})
|
||||||
vim.keymap.set('n', '<leader>f?', builtin.builtin, {})
|
vim.keymap.set('n', '<leader>f?', builtin.builtin, {})
|
||||||
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
|
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
|
||||||
|
vim.keymap.set('n', '<leader>fr', builtin.command_history, {})
|
||||||
vim.keymap.set('n', '<leader>fc', builtin.commands, {})
|
vim.keymap.set('n', '<leader>fc', builtin.commands, {})
|
||||||
vim.keymap.set('n', '<leader>ft', builtin.treesitter, {})
|
vim.keymap.set('n', '<leader>ft', builtin.treesitter, {})
|
||||||
EOF
|
EOF
|
||||||
|
|
Loading…
Reference in a new issue