mirror of
https://github.com/He4eT/dotfiles.git
synced 2026-05-04 23:47:23 +00:00
nvim: add stylua
This commit is contained in:
parent
95d04c5cd4
commit
96e2fd2964
2 changed files with 57 additions and 44 deletions
6
nvim/.stylua.toml
Normal file
6
nvim/.stylua.toml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
column_width = 160
|
||||||
|
line_endings = "Unix"
|
||||||
|
indent_type = "Spaces"
|
||||||
|
indent_width = 2
|
||||||
|
quote_style = "AutoPreferSingle"
|
||||||
|
call_parentheses = "None"
|
||||||
|
|
@ -115,9 +115,15 @@ require('lazy').setup({
|
||||||
config = function()
|
config = function()
|
||||||
vim.g.codeium_manual = 1
|
vim.g.codeium_manual = 1
|
||||||
vim.g.codeium_disable_bindings = 1
|
vim.g.codeium_disable_bindings = 1
|
||||||
vim.keymap.set('i', '<C-h>', function() return vim.fn['codeium#Complete']() end, { expr = true })
|
vim.keymap.set('i', '<C-h>', function()
|
||||||
vim.keymap.set('i', '<C-l>', function() return vim.fn['codeium#Accept']() end, { expr = true })
|
return vim.fn['codeium#Complete']()
|
||||||
vim.keymap.set('i', '<C-u>', function() return vim.fn['codeium#Clear']() end, { expr = true })
|
end, { expr = true })
|
||||||
|
vim.keymap.set('i', '<C-l>', function()
|
||||||
|
return vim.fn['codeium#Accept']()
|
||||||
|
end, { expr = true })
|
||||||
|
vim.keymap.set('i', '<C-u>', function()
|
||||||
|
return vim.fn['codeium#Clear']()
|
||||||
|
end, { expr = true })
|
||||||
|
|
||||||
vim.keymap.set('i', '<C-j>', function()
|
vim.keymap.set('i', '<C-j>', function()
|
||||||
vim.fn['codeium#CycleCompletions'](1)
|
vim.fn['codeium#CycleCompletions'](1)
|
||||||
|
|
@ -301,9 +307,9 @@ require('leap').opts.highlight_unlabeled_phase_one_targets = true
|
||||||
require('leap').opts.safe_labels = {}
|
require('leap').opts.safe_labels = {}
|
||||||
|
|
||||||
-- [[ Configure fzf-lua ]]
|
-- [[ Configure fzf-lua ]]
|
||||||
local fzf = require('fzf-lua')
|
local fzf = require 'fzf-lua'
|
||||||
|
|
||||||
fzf.setup({
|
fzf.setup {
|
||||||
winopts = {
|
winopts = {
|
||||||
border = 'single',
|
border = 'single',
|
||||||
fullscreen = true,
|
fullscreen = true,
|
||||||
|
|
@ -311,21 +317,21 @@ fzf.setup({
|
||||||
builtin = {
|
builtin = {
|
||||||
syntax = true,
|
syntax = true,
|
||||||
syntax_limit_b = 1024 * 64, -- syntax limit (bytes), 0=nolimit
|
syntax_limit_b = 1024 * 64, -- syntax limit (bytes), 0=nolimit
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
grep = {
|
grep = {
|
||||||
rg_opts = '--vimgrep --smart-case --max-columns=512' ..
|
rg_opts = '--vimgrep --smart-case --max-columns=512'
|
||||||
' --color=ansi' ..
|
.. ' --color=ansi'
|
||||||
' --colors path:fg:yellow' ..
|
.. ' --colors path:fg:yellow'
|
||||||
' --colors line:fg:green' ..
|
.. ' --colors line:fg:green'
|
||||||
' --colors column:fg:blue' ..
|
.. ' --colors column:fg:blue'
|
||||||
' --colors match:fg:red',
|
.. ' --colors match:fg:red',
|
||||||
file_ignore_patterns = {
|
file_ignore_patterns = {
|
||||||
'^node_modules/',
|
'^node_modules/',
|
||||||
'/node_modules/',
|
'/node_modules/',
|
||||||
'^.git/',
|
'^.git/',
|
||||||
'^.yarn/'
|
'^.yarn/',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
fzf_opts = {
|
fzf_opts = {
|
||||||
|
|
@ -347,10 +353,10 @@ fzf.setup({
|
||||||
['header'] = { 'fg', 'Comment' },
|
['header'] = { 'fg', 'Comment' },
|
||||||
['gutter'] = { 'bg', 'Normal' },
|
['gutter'] = { 'bg', 'Normal' },
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|
||||||
local fzf_files = function()
|
local fzf_files = function()
|
||||||
fzf.files({ fd_opts = '--no-ignore --hidden' })
|
fzf.files { fd_opts = '--no-ignore --hidden' }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- fzf keymaps
|
-- fzf keymaps
|
||||||
|
|
@ -379,7 +385,7 @@ vim.keymap.set({ 'n' }, '<leader>f:', fzf.command_history, { desc = '[F]zf: comm
|
||||||
|
|
||||||
-- [[ Configure Treesitter ]]
|
-- [[ Configure Treesitter ]]
|
||||||
-- See `:help nvim-treesitter`
|
-- See `:help nvim-treesitter`
|
||||||
require('nvim-treesitter.configs').setup({
|
require('nvim-treesitter.configs').setup {
|
||||||
-- Add languages to be installed here that you want installed for treesitter
|
-- Add languages to be installed here that you want installed for treesitter
|
||||||
ensure_installed = {
|
ensure_installed = {
|
||||||
'vim',
|
'vim',
|
||||||
|
|
@ -450,7 +456,7 @@ require('nvim-treesitter.configs').setup({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|
||||||
-- [[ LSP settings ]]
|
-- [[ LSP settings ]]
|
||||||
-- This function gets run when an LSP connects to a particular buffer.
|
-- This function gets run when an LSP connects to a particular buffer.
|
||||||
|
|
@ -497,8 +503,7 @@ end
|
||||||
-- Add any additional override configuration in the following tables. They will be passed to
|
-- Add any additional override configuration in the following tables. They will be passed to
|
||||||
-- the `settings` field of the server config. You must look up that documentation yourself.
|
-- the `settings` field of the server config. You must look up that documentation yourself.
|
||||||
local servers = {
|
local servers = {
|
||||||
tsserver = {
|
tsserver = {},
|
||||||
},
|
|
||||||
lua_ls = {
|
lua_ls = {
|
||||||
Lua = {
|
Lua = {
|
||||||
workspace = { checkThirdParty = false },
|
workspace = { checkThirdParty = false },
|
||||||
|
|
@ -514,17 +519,17 @@ capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
||||||
-- Ensure the servers above are installed
|
-- Ensure the servers above are installed
|
||||||
local mason_lspconfig = require 'mason-lspconfig'
|
local mason_lspconfig = require 'mason-lspconfig'
|
||||||
|
|
||||||
mason_lspconfig.setup({
|
mason_lspconfig.setup {
|
||||||
ensure_installed = vim.tbl_keys(servers),
|
ensure_installed = vim.tbl_keys(servers),
|
||||||
})
|
}
|
||||||
|
|
||||||
mason_lspconfig.setup_handlers {
|
mason_lspconfig.setup_handlers {
|
||||||
function(server_name)
|
function(server_name)
|
||||||
require('lspconfig')[server_name].setup({
|
require('lspconfig')[server_name].setup {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
settings = servers[server_name],
|
settings = servers[server_name],
|
||||||
})
|
}
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -532,7 +537,7 @@ vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, {
|
||||||
border = 'solid',
|
border = 'solid',
|
||||||
})
|
})
|
||||||
|
|
||||||
require('lspconfig').tsserver.setup({
|
require('lspconfig').tsserver.setup {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
handlers = {
|
handlers = {
|
||||||
|
|
@ -542,7 +547,7 @@ require('lspconfig').tsserver.setup({
|
||||||
['_typescript.rename'] = function(_, result)
|
['_typescript.rename'] = function(_, result)
|
||||||
local line = result.position.line
|
local line = result.position.line
|
||||||
local character = result.position.character
|
local character = result.position.character
|
||||||
local column = vim.str_byteindex(vim.fn.getline('.'), character, true)
|
local column = vim.str_byteindex(vim.fn.getline '.', character, true)
|
||||||
vim.api.nvim_win_set_cursor(0, { line + 1, column })
|
vim.api.nvim_win_set_cursor(0, { line + 1, column })
|
||||||
vim.lsp.buf.rename()
|
vim.lsp.buf.rename()
|
||||||
return result
|
return result
|
||||||
|
|
@ -553,20 +558,20 @@ require('lspconfig').tsserver.setup({
|
||||||
result = vim.tbl_islist(result) and result[1] or result
|
result = vim.tbl_islist(result) and result[1] or result
|
||||||
vim.lsp.handlers['textDocument/definition'](err, result, ...)
|
vim.lsp.handlers['textDocument/definition'](err, result, ...)
|
||||||
end,
|
end,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
-- nvim-cmp setup
|
-- nvim-cmp setup
|
||||||
local cmp = require 'cmp'
|
local cmp = require 'cmp'
|
||||||
local luasnip = require 'luasnip'
|
local luasnip = require 'luasnip'
|
||||||
|
|
||||||
luasnip.config.setup({
|
luasnip.config.setup {
|
||||||
-- https://stackoverflow.com/questions/70366949/
|
-- https://stackoverflow.com/questions/70366949/
|
||||||
region_check_events = "CursorHold,InsertLeave",
|
region_check_events = 'CursorHold,InsertLeave',
|
||||||
delete_check_events = "TextChanged,InsertEnter",
|
delete_check_events = 'TextChanged,InsertEnter',
|
||||||
})
|
}
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup {
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
luasnip.lsp_expand(args.body)
|
luasnip.lsp_expand(args.body)
|
||||||
|
|
@ -603,7 +608,9 @@ cmp.setup({
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
{ name = 'luasnip' },
|
{ name = 'luasnip' },
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|
||||||
|
-- npx @johnnymorganz/stylua-bin ./init.lua
|
||||||
|
|
||||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
-- The line beneath this is called `modeline`. See `:help modeline`
|
||||||
-- vim: ts=2 sts=2 sw=2 et
|
-- vim: ts=2 sts=2 sw=2 et
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue